Skip to content

Commit

Permalink
Merge pull request #136 from joemarshall/numpy_chunk
Browse files Browse the repository at this point in the history
Make chunk use numpy (and optimise with numba)
  • Loading branch information
pppalain authored Jan 29, 2024
2 parents fe1729c + 2010c3f commit b3c1eed
Show file tree
Hide file tree
Showing 42 changed files with 145,406 additions and 2,535 deletions.
17 changes: 3 additions & 14 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Cache blender
id: cache-blender
if: runner.os != 'macOS'
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: blender
key: ${{ matrix.os }}-${{ matrix.blender_version}}-blender
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
shutil.unpack_archive("${{ steps.download.outputs.BLENDER_ARCHIVE }}","blender")
shell: python
- name: Save blender
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: steps.cache-blender.outputs.cache-hit != 'true' && runner.os != 'macOS'
with:
path: blender
Expand All @@ -79,21 +79,10 @@ jobs:
export ADDON_PATH=${PWD}/scripts/addons/blendercam.zip
cd scripts/addons/cam/tests
python install_addon.py ${ADDON_PATH}
python test_suite.py
python test_suite.py -vvv
- uses: actions/upload-artifact@v4
if: always()
with:
name: blendercam-${{matrix.os}}-${{matrix.blender_version}}
path: ./scripts/addons/cam
rerun-failed-jobs:
runs-on: ubuntu-latest
needs: [ build_and_test ]
if: failure()
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Rerun failed jobs in the current workflow (because mac blender is unstable)
env:
GH_TOKEN: ${{ github.token }}
run: gh run rerun ${{ github.run_id }} --failed

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ forceSyncWithUpstream
.project

.pydevproject
__pycache__/
temp_cam/
6 changes: 3 additions & 3 deletions scripts/addons/cam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENCE BLOCK *****

import bgl
# ***** END GPL LICENCE BLOCK ****
import bl_operators
import blf
import bpy
Expand All @@ -43,6 +41,8 @@
subprocess.check_call([sys.executable, "-m", "ensurepip"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", " pip"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "shapely","Equation","opencamlib"])
# install numba if available for this platform, ignore failure
subprocess.run([sys.executable, "-m", "pip", "install", "numba"])


from bpy.app.handlers import persistent
Expand Down
5 changes: 5 additions & 0 deletions scripts/addons/cam/async_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def __init__(self):
self._is_cancelled=False

def modal(self,context,event):
if bpy.app.background:
return {'PASS_THROUGH'}

if event.type == 'TIMER':
try:
if self.tick(context):
Expand Down Expand Up @@ -70,6 +73,8 @@ def tick(self,context):
return True
except StopIteration:
return False
except Exception as e:
print("Exception thrown in tick:",e)

def execute(self, context):
if bpy.app.background:
Expand Down
2 changes: 2 additions & 0 deletions scripts/addons/cam/autoupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class UpdateChecker(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO'}

def execute(self, context):
if bpy.app.background:
return {"FINISHED"}
last_update_check = bpy.context.preferences.addons['cam'].preferences.last_update_check
today=date.today().toordinal()
update_source = bpy.context.preferences.addons['cam'].preferences.update_source
Expand Down
15 changes: 8 additions & 7 deletions scripts/addons/cam/bridges.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,21 @@ def useBridges(ch, o):

vi = 0
newpoints = []
p1 = sgeometry.Point(ch.points[0])
ch_points=ch.get_points_np()
p1 = sgeometry.Point(ch_points[0])
startinside = o.bridgespoly.contains(p1)
interrupted = False
verts = []
edges = []
faces = []
while vi < len(ch.points):
while vi < len(ch_points):
i1 = vi
i2 = vi
chp1 = ch.points[i1]
chp2 = ch.points[i1] # Vector(v1)#this is for case of last point and not closed chunk..
if vi + 1 < len(ch.points):
chp1 = ch_points[i1]
chp2 = ch_points[i1] # Vector(v1)#this is for case of last point and not closed chunk..
if vi + 1 < len(ch_points):
i2 = vi + 1
chp2 = ch.points[vi + 1] # Vector(ch.points[vi+1])
chp2 = ch_points[vi + 1] # Vector(ch_points[vi+1])
v1 = mathutils.Vector(chp1)
v2 = mathutils.Vector(chp2)
if v1.z < bridgeheight or v2.z < bridgeheight:
Expand Down Expand Up @@ -230,7 +231,7 @@ def useBridges(ch, o):
newpoints.append(chp1)
vi += 1
interrupted = True
ch.points = newpoints
ch.set_points(newpoints)

# create bridge cut curve here
count = 0
Expand Down
Loading

0 comments on commit b3c1eed

Please sign in to comment.