friggog / tree-gen

Procedural generation of tree models in blender
GNU General Public License v3.0
827 stars 74 forks source link

Blender 2.80 compatibility #18

Closed samipfjo closed 5 years ago

samipfjo commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

arpu commented 5 years ago

https://code.blender.org/2018/10/blender-2-8-beta-and-roadmap/

samipfjo commented 5 years ago

API changes are not my concern here.

My concern is unresolved bugs that are present in every beta version of software -- hence being a beta version and not a release. They have the potential to waste a lot of development time trying to figure out why something in the addon isn't working when it's related to a bug that will be fixed when 2.8 is released.

If you would like to give it a shot, feel free to do so and send a PR; I'll happily do a code review, and I'm sure @friggog will too, considering he is the project's Benevolent Dictator For Life ;)

friggog commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

friggog commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

On line 24 of parametric/gen.py, try changing stem.curve.bezier_points.add() to stem.curve.bezier_points.add(1).

I unfortunately do not have a computer in front of me to test the code, and this is a shot in the dark, but give it a try.

Thanks much for doing the work to convert the GUI code! That's a huge help!

On Thu, Jul 4, 2019, 6:53 PM Oxer notifications@github.com wrote:

Hi again, I got taht 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.

[image: TreeGen 2 80] https://user-images.githubusercontent.com/46649474/60692818-1ab98080-9ed8-11e9-9fc6-c666691d33ca.gif

Here TreeGen modified to 2.80

ch_trees 2.80.zip https://github.com/friggog/tree-gen/files/3360836/ch_trees.2.80.zip

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/friggog/tree-gen/issues/18?email_source=notifications&email_token=ABQGAD6M4WIBAZOMFAOQB43P52SRVA5CNFSM4GJZKCPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZIK6ZQ#issuecomment-508604262, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQGAD4EAJXYKNBRMHADO3LP52SRVANCNFSM4GJZKCPA .

friggog commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

You are a rockstar. Thank you so much for your work.

These errors shouldn't be hard to fix, but like @friggog said, you will need to fork the codebase and create a pull request.

The first thing you should do is back up all of your changes and save the zip file to your desktop. After that:

1) Install the GitHub desktop app 2) Follow the instructions here: https://help.github.com/en/articles/fork-a-repo

On Fri, Jul 5, 2019, 8:15 AM Oxer notifications@github.com wrote:

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 ot 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

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

[image: Trees in 2 80] https://user-images.githubusercontent.com/46649474/60731180-33ad4a80-9f47-11e9-83a2-08490b8d1f22.jpg

Addon modified to 2.80 with Tree creation working: ch_trees.zip https://github.com/friggog/tree-gen/files/3363248/ch_trees.zip

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/friggog/tree-gen/issues/18?email_source=notifications&email_token=ABQGAD33UY6U5ZKWPGZPZTTP55QRTA5CNFSM4GJZKCPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZJYO6I#issuecomment-508790649, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQGAD3ZWFMS5VB6US6SWSLP55QRTANCNFSM4GJZKCPA .

Oxervision commented 5 years ago

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 commented 5 years ago

Add a summary, something like "Initial 2.8 compatibility changes", then hit "commit" (over on the left-hand side under the list of files). I think the GitHub app will automatically update the online ("upstream") repository (called a "push"), but I don't recall, so make sure the online version has one of the changes you've made.

After that, go to the main page of your forked repository (where you took your most recent screenshot) and press "New pull request". Submit that, and you should be good to go.

On Fri, Jul 5, 2019, 9:54 AM Oxer notifications@github.com wrote:

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

[image: Repo Forked] https://user-images.githubusercontent.com/46649474/60735964-a6252700-9f55-11e9-9db5-d041db2aab91.jpg

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

[image: Files changed] https://user-images.githubusercontent.com/46649474/60735931-7c6c0000-9f55-11e9-8d06-5b6f3a31d060.jpg

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/friggog/tree-gen/issues/18?email_source=notifications&email_token=ABQGAD6FCRVNUOCWIGW7D3DP554FRA5CNFSM4GJZKCPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZJ6OHA#issuecomment-508815132, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQGAD7O6ZQDCA5L63IUQRDP554FRANCNFSM4GJZKCPA .

samipfjo commented 5 years ago

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

Oxervision commented 5 years ago

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

Oxervision commented 5 years ago

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

samipfjo commented 5 years ago

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 commented 5 years ago

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

samipfjo commented 5 years ago

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 commented 5 years ago

:) 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 commented 5 years ago

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 commented 5 years ago

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:

samipfjo commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

Had an hour train ride this morning so started fixing things: da3e18feb8cc55769da2a466a871fcadd549cd84. 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 commented 5 years ago

https://github.com/friggog/tree-gen/commit/ebda1d6522c5fb8f1e9ffa50cf7b2592c1b35500 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)