Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNBurn <7nburn@gmail.com>2019-01-29 18:54:49 +0300
committerNBurn <7nburn@gmail.com>2019-01-29 18:54:49 +0300
commitd609009748a604c1df2d8babfa4098260666d01a (patch)
tree98150e04df48252889e2fc8e049c13115e0afe72 /object_fracture_cell
parent5c994fde52196dfe8a7e0db03b6935bac001d353 (diff)
addons: objects.link/unlink syntax update
Changed objects.link and objects.unlink from scene to collection
Diffstat (limited to 'object_fracture_cell')
-rw-r--r--object_fracture_cell/__init__.py15
-rw-r--r--object_fracture_cell/fracture_cell_setup.py14
2 files changed, 17 insertions, 12 deletions
diff --git a/object_fracture_cell/__init__.py b/object_fracture_cell/__init__.py
index f4122d33..75da5e28 100644
--- a/object_fracture_cell/__init__.py
+++ b/object_fracture_cell/__init__.py
@@ -45,7 +45,7 @@ from bpy.props import (
from bpy.types import Operator
-def main_object(scene, obj, level, **kw):
+def main_object(context, obj, level, **kw):
import random
# pull out some args
@@ -66,6 +66,8 @@ def main_object(scene, obj, level, **kw):
use_sharp_edges = kw_copy.pop("use_sharp_edges")
use_sharp_edges_apply = kw_copy.pop("use_sharp_edges_apply")
+ collection = context.collection
+
if level != 0:
kw_copy["source_limit"] = recursion_source_limit
@@ -78,8 +80,8 @@ def main_object(scene, obj, level, **kw):
obj_display_type_prev = obj.display_type
obj.display_type = 'WIRE'
- objects = fracture_cell_setup.cell_fracture_objects(scene, obj, **kw_copy)
- objects = fracture_cell_setup.cell_fracture_boolean(scene, obj, objects,
+ objects = fracture_cell_setup.cell_fracture_objects(context, obj, **kw_copy)
+ objects = fracture_cell_setup.cell_fracture_boolean(context, obj, objects,
use_island_split=use_island_split,
use_interior_hide=(use_interior_vgroup or use_sharp_edges),
use_debug_bool=use_debug_bool,
@@ -123,9 +125,9 @@ def main_object(scene, obj, level, **kw):
objects_recursive = []
for i, obj_cell in objects_recurse_input:
assert(objects[i] is obj_cell)
- objects_recursive += main_object(scene, obj_cell, level_sub, **kw)
+ objects_recursive += main_object(context, obj_cell, level_sub, **kw)
if use_remove_original:
- scene.objects.unlink(obj_cell)
+ collection.objects.unlink(obj_cell)
del objects[i]
if recursion_clamp and len(objects) + len(objects_recursive) >= recursion_clamp:
break
@@ -182,7 +184,6 @@ def main_object(scene, obj, level, **kw):
def main(context, **kw):
import time
t = time.time()
- scene = context.scene
objects_context = context.selected_editable_objects
kw_copy = kw.copy()
@@ -194,7 +195,7 @@ def main(context, **kw):
objects = []
for obj in objects_context:
if obj.type == 'MESH':
- objects += main_object(scene, obj, 0, **kw_copy)
+ objects += main_object(context, obj, 0, **kw_copy)
bpy.ops.object.select_all(action='DESELECT')
for obj_cell in objects:
diff --git a/object_fracture_cell/fracture_cell_setup.py b/object_fracture_cell/fracture_cell_setup.py
index 2b46715f..fcd65681 100644
--- a/object_fracture_cell/fracture_cell_setup.py
+++ b/object_fracture_cell/fracture_cell_setup.py
@@ -121,7 +121,7 @@ def _points_from_object(obj, source):
return points
-def cell_fracture_objects(scene, obj,
+def cell_fracture_objects(context, obj,
source={'PARTICLE_OWN'},
source_limit=0,
source_noise=0.0,
@@ -137,6 +137,8 @@ def cell_fracture_objects(scene, obj,
):
from . import fracture_cell_calc
+ collection = context.collection
+ scene = context.scene
# -------------------------------------------------------------------------
# GET POINTS
@@ -187,7 +189,7 @@ def cell_fracture_objects(scene, obj,
bm.to_mesh(mesh_tmp)
bm.free()
obj_tmp = bpy.data.objects.new(name=mesh_tmp.name, object_data=mesh_tmp)
- scene.objects.link(obj_tmp)
+ collection.objects.link(obj_tmp)
del obj_tmp, mesh_tmp
mesh = obj.data
@@ -278,7 +280,7 @@ def cell_fracture_objects(scene, obj,
# OBJECT
obj_cell = bpy.data.objects.new(name=cell_name, object_data=mesh_dst)
- scene.objects.link(obj_cell)
+ collection.objects.link(obj_cell)
# scene.objects.active = obj_cell
obj_cell.location = center_point
@@ -309,7 +311,7 @@ def cell_fracture_objects(scene, obj,
return objects
-def cell_fracture_boolean(scene, obj, objects,
+def cell_fracture_boolean(context, obj, objects,
use_debug_bool=False,
clean=True,
use_island_split=False,
@@ -320,6 +322,8 @@ def cell_fracture_boolean(scene, obj, objects,
):
objects_boolean = []
+ collection = context.collection
+ scene = context.scene
if use_interior_hide and level == 0:
# only set for level 0
@@ -346,7 +350,7 @@ def cell_fracture_boolean(scene, obj, objects,
if not mesh_old.users:
bpy.data.meshes.remove(mesh_old)
if not mesh_new.vertices:
- scene.objects.unlink(obj_cell)
+ collection.objects.unlink(obj_cell)
if not obj_cell.users:
bpy.data.objects.remove(obj_cell)
obj_cell = None