Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions .github/workflows/CD.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: build
on:
push:
tags:
- '**'
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
extension: bat
name: windows
- os: ubuntu-latest
extension: sh
name: linux
- os: macos-latest
extension: osx
name: macOS
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
submodules: true
- name: setup python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: generate cmake files
run: cmake -S src -B build
- name: build
run: cmake --build build

- name: upload addon
uses: actions/upload-artifact@v4
with:
name: modular_tree_${{ matrix.name }}
path: addon

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
- name: Display structure of downloaded files
run: ls -R
- name: Zip artifacts
run: |
for dir in modular_tree_*; do
if [ -d "$dir" ]; then
zip -r "${dir}.zip" "${dir}"
fi
done
- name: Create release
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag'
with:
files: modular_tree_*.zip
55 changes: 13 additions & 42 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,42 +1,13 @@
*/build/
*__pycache__/
*Debug/
m_tree/m_tree.egg-info/


# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
*.pyd
*.pdb
**/.vscode/
m_tree.egg-info/
*.exp
*/binaries/
tmp/*
# IDEs
**/.idea
**/.vscode
**/.vs

# Misc
**/__pycache__

# Build
build
addon/lib/*.pyd
addon/lib/*.pdb
*.zip
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Note!
This repository is a fork that supports 4.2+ Blender versions. It is built with Python 3.11, which is currently bundled into Blender.

It has changes to the build process, making it easier to update in the future.


# Mtree

Mtree (previously Modular Tree) is a library for making 3d trees. It comes as an addon for blender but the c++ library can be used separately.
Expand All @@ -14,19 +20,21 @@ Mtree (previously Modular Tree) is a library for making 3d trees. It comes as an


## Installation (blender addon)
Go to the [latest release]. Under `Assets`, select the version corresponding to your os.\
Follow the [blender documentation][blender addon doc] to install the downloaded addon.
Go to the [latest release]. Under `Assets`, select the version corresponding to your os.

Follow the [Blender documentation][blender addon doc] to install the downloaded addon.

## Development
### Dependencies
- [Cmake]
- Blender 2.93 or higher (if you want to to develop the blender addon)
- Blender 4.2 or higher

### Installation
1. Clone the repository reccursively `git clone --recursive https://github.com/MaximeHerpin/modular_tree`
2. Execute the `build_mtree` bash script corresponding to your platform.
3. If all went well, a cmake project has been generated under `mtree/build`.
4. You can bundle the blender addon by calling the [addon bundling script].
1. Clone the repository reccursively `git clone https://github.com/ethanporcaro/modular_tree_py311`
2. Generate Cmake files with `cmake -S src -B build`
3. Build the project with `cmake --build build`
3. If all went well, your addon will be generated and zipped to `modular_tree_{platform}.zip` where `{platform}` is the name of your operating system.


### Usage
A `Tree` is generated by executing a succession of `TreeFunction`. When being executed, a `TreeFunction` modifies the structure of the tree, and then calls children functions recursively.\
Expand Down Expand Up @@ -60,7 +68,7 @@ trunk->add_child(branches_dead);
Tree tree(trunk);
```
## License
Blender being under the GPL license, the blender addon (all files under `python_classes` as well as `__init__.py`) is under the [GPLv3] license.\
Blender being under the GPL license, the blender addon (all files under `addon`) is under the [GPLv3] license.\
The Mtree library is under the [MIT] license.


Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4_0_2
5_0_0
33 changes: 15 additions & 18 deletions __init__.py → addon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,26 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os
from pathlib import Path
from . import python_classes

from . import nodes
from . import operators

bl_info = {
"name" : "Modular Tree",
"author" : "Maxime",
"description" : "create trees",
"blender" : (2, 83, 0),
"version" : (4, 0, 2),
"location" : "",
"warning" : "",
"category" : "Generic"
"name": "Modular Tree",
"author": "Maxime",
"description": "create trees",
"blender": (4, 4, 3),
"version": (5, 0, 0),
"location": "",
"warning": "",
"category": "Generic"
}


# auto_load.init()

def register():
python_classes.register()
# auto_load.register()
operators.register()
nodes.register()


def unregister():
python_classes.unregister()
# auto_load.unregister()
operators.unregister()
nodes.unregister()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import bpy
from ..base_types.node import MtreePropertyNode
from ....m_tree import SimpleCurveProperty, PropertyWrapper
from ...lib.m_tree import SimpleCurveProperty, PropertyWrapper

class RampPropertyNode(bpy.types.Node, MtreePropertyNode):
bl_idname = "mt_RampPropertyNode"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import bpy
from ..base_types.node import MtreePropertyNode
from ....m_tree import RandomProperty, PropertyWrapper
from ...lib.m_tree import RandomProperty, PropertyWrapper

class RandomPropertyNode(bpy.types.Node, MtreePropertyNode):
bl_idname = "mt_RandomPropertyNode"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import bpy
from ..base_types.socket import MtreeSocket
from ....m_tree import ConstantProperty, RandomProperty, PropertyWrapper
from ...lib.m_tree import ConstantProperty, RandomProperty, PropertyWrapper

class MtreePropertySocket(bpy.types.NodeSocket, MtreeSocket):
bl_idname = 'mt_PropertySocket'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from random import randint
import bpy
from ..base_types.node import MtreeFunctionNode
from ....m_tree import BranchFunction
from ...lib.m_tree import BranchFunction

class BranchNode(bpy.types.Node, MtreeFunctionNode):
bl_idname = "mt_BranchNode"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import bpy
from ..base_types.node import MtreeFunctionNode
from ....m_tree import PipeRadiusFunction
from ...lib.m_tree import PipeRadiusFunction

class PipeRadiusNode(bpy.types.Node, MtreeFunctionNode):
bl_idname = "mt_PipeRadiusNode"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import time
import numpy as np
import bpy
from .... import m_tree
from ...lib import m_tree
from ..base_types.node import MtreeNode

def on_update_prop(node, context):
Expand Down Expand Up @@ -103,12 +103,12 @@ def fill_blender_mesh(self, mesh, cpp_mesh):
mesh.loops.add(len(faces))
mesh.loops.foreach_set("vertex_index", faces)

loop_start = np.arange(0, len(faces), 4, dtype=np.int)
loop_total = np.ones(len(faces)//4, dtype = np.int)*4
loop_start = np.arange(0, len(faces), 4, dtype=int)
loop_total = np.ones(len(faces)//4, dtype = int)*4
mesh.polygons.add(len(faces)//4)
mesh.polygons.foreach_set("loop_start", loop_start)
mesh.polygons.foreach_set("loop_total", loop_total)
mesh.polygons.foreach_set('use_smooth', np.ones(len(faces)//4, dtype=np.bool))
mesh.polygons.foreach_set('use_smooth', np.ones(len(faces)//4, dtype=bool))


uv_data = cpp_mesh.get_uvs()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from random import randint
import bpy
from ..base_types.node import MtreeFunctionNode
from ....m_tree import TrunkFunction
from ...lib.m_tree import TrunkFunction

class TrunkNode(bpy.types.Node, MtreeFunctionNode):
bl_idname = "mt_TrunkNode"
Expand Down
2 changes: 1 addition & 1 deletion python_classes/operators.py → addon/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import gpu
import numpy as np

from .. import m_tree
from .lib import m_tree
from .resources.node_groups import distribute_leaves


Expand Down
File renamed without changes.
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
import bpy

MTREE_RESOURCE_DIR = (Path(__file__).parent.parent.parent / "resources").resolve()
MTREE_RESOURCE_DIR = Path(__file__).parent.resolve()

class ResourceUtils:

Expand All @@ -13,7 +13,7 @@ def append_geo_node(cls, name:str):
group = bpy.data.node_groups.get(name, None)

if group is None:
directory = os.path.join(cls.geo_nodes_dir, "geo_nodes_2_93.blend", "NodeTree")
directory = os.path.join(cls.geo_nodes_dir, "geo_nodes.blend", "NodeTree")
filepath = os.path.join(directory, name)
bpy.ops.wm.append(filepath=filepath,filename=name,directory=directory, autoselect=False)
group = bpy.data.node_groups[name]
Expand Down
Loading