-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurve_ivy_animated.py
725 lines (618 loc) · 22.6 KB
/
curve_ivy_animated.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
###########################################################
import bpy, bmesh
import numpy as np
import asyncio as aio
from bpy.types import Operator, Panel, PropertyGroup
from bpy.props import BoolProperty, EnumProperty, StringProperty, IntProperty, FloatProperty, PointerProperty, FloatVectorProperty
from bpy.app.handlers import persistent
from mathutils import Vector, Matrix, Euler, noise
from mathutils.bvhtree import BVHTree
from mathutils.geometry import distance_point_to_plane
from random import random, seed
#uncomment in update_ivy to avoid endless adding
#dspl = bpy.types.WindowManager.display
###########################################################
_DEBUG = False
def printd(*args):
if _DEBUG: print(*args)
###########################################################
def update_func(self, context):
context.scene.frame_set(context.scene.frame_current)
def update_func_endframe(self, context):
opt = context.active_object.ivy
if opt.end < opt.start:
opt.end = opt.start+1
return
context.scene.frame_set(context.scene.frame_current)
#this does not work (do not know how to set the value)
def update_on_set(self, value):
self = value
bpy.context.scene.frame_set(bpy.context.scene.frame_current)
return None
def rvec():
return Vector((random()-.5, random()-.5, random()-.5)).normalized()
def new_spline(splines, coords):
spline = splines.new('POLY')
spline.points.add(count=len(coords)-1)
coords = [co.to_4d() for co in coords]
array = []
[array.extend(v) for v in coords]
spline.points.foreach_set('co', array)
spline.points[-1].radius = 0
if len(spline.points) > 1:
spline.points[-2].radius = 0.5
if len(spline.points) > 2:
spline.points[-3].radius = 0.75
return spline
def create_splines(ivy, coords_list):
splines = ivy.data.splines
splines.clear()
for coords in coords_list:
new_spline(splines, coords)
def get_spline_coords(ivy, branchidx):
'''Does work now, but not used'''
splines = ivy.data.splines
if branchidx > len(splines)-1:
return []
spline = splines[branchidx]
coords = [0]*len(spline.points)*4
spline.points.foreach_get('co', coords)
return coords
#COLLIDER IN IVY_SPACE
def collider_in_ivy_space(context, ivy):
if ivy.ivy.collider:
if not ivy.ivy.collider in context.scene.objects:
return None
collider = context.scene.objects[ivy.ivy.collider]
me = collider.to_mesh(context.scene, True, settings='PREVIEW')
bm = bmesh.new()
bm.from_mesh(me)
bm.transform(collider.matrix_world)
bm.transform(ivy.matrix_world.inverted())
return bm
return None
#Fallof curve
def sigmoid( x, weight=1, offset=0, derivative=False):
"""weight=10, offset=0.5 for 0-1 S-curve"""
if not derivative:
return 1 / (1 + np.exp(-(x-offset)*weight))
else:
out = sigmoid(x, weight, offset)
return out * (1 - out)
### GROWTH VECTOR
def growvec(opt, coords, bvh, freefloatinglength):
#RANDOM Vector
vec_random = rvec()
vec_random *= opt.scale_random
#UP Vector
vec_up = Vector((0,0,1))
if freefloatinglength and opt.stiffness_up:
stiffness_range = opt.stiffness_up / freefloatinglength
up_influence = sigmoid(stiffness_range, 10, 0.5)
vec_up *= 1 - up_influence
vec_up *= opt.scale_up
#dspl.add_edge([coords[-1], coords[-1]+vec_up])
#STRAIGHT Vector
if len(coords) > 1:
vec_straight = (coords[-1] - coords[-2]).normalized()
else:
vec_straight = Vector((0,0,0))
vec_straight *= opt.scale_straight
#GRAVITY Vector
vec_grav = Vector((0,0,-1))
if freefloatinglength and opt.scale_gravity and opt.stiffness_gravity:
stiffness_range = opt.stiffness_gravity / freefloatinglength
grav_influence = sigmoid(stiffness_range, -10, 0.5)
vec_grav *= grav_influence
vec_grav *= opt.scale_gravity
#dspl.add_edge([coords[-1], coords[-1]+vec_grav])
#ADHESION Vector
vec_adhesion = Vector((0,0,0))
if opt.has_collider:
vec_adhesion = adhesion(opt, coords[-1], bvh, freefloatinglength)
#COMBINE TO GROWTH VECTOR
vec_grow = vec_random + vec_up + vec_straight + vec_grav + vec_adhesion
#SET SCALE
vec_grow = vec_grow.normalized()
vec_grow.length = opt.scale
return vec_grow
### ADHESION
def adhesion(opt, co, bvh, freefloatinglength):
### BASIS ADHESION VECTOR
hit, normal, face, distance = bvh.find_nearest(co)
vec_adhesion = (hit - co).normalized() * opt.scale
### DISTANCE MODIFICATION
if opt.max_dist_adhesion:
#this atenuates the force from max dist (no influence) to zero dist (max influence)
relative_distance = distance / opt.max_dist_adhesion
distance_influence = sigmoid(relative_distance, weight=-10, offset=0.5)
vec_adhesion *= distance_influence
### CORNERS - BACKFACING MODIFICATION
ray_hit, ray_normal, ray_face, ray_distance = bvh.ray_cast(co, -normal, distance*2)
if ray_hit is None:
if (co-hit).dot(normal) > 0:
angle = (co-hit).angle(normal)
angle_range = angle / (np.pi/2)
angle_influence = sigmoid(angle_range, weight=10, offset=0.5) * opt.adhesion_angle_influence
vec_adhesion *= angle_influence
else:
vec_adhesion *= 0
### FREE FLOATING DISTANCE MODIFICATION
#modify by freefloatingdistance
if freefloatinglength and opt.adhesion_floating_influence and opt.adhesion_floating_length:
relative_distance = freefloatinglength / opt.adhesion_floating_length
floating_influence = sigmoid(relative_distance, -10, 0.5) * opt.adhesion_floating_influence
vec_adhesion *= floating_influence
#dspl.add_edge([co, co+vec_adhesion], k=[round(freefloatinglength,4), np.round(floating_influence,4)])
### GLOBAL ADHESION SCALE
vec_adhesion *= opt.scale_adhesion
#dspl.add_edge([co, co+vec_adhesion])
return vec_adhesion
### COLLISION
def collision(opt, last_co, next_co, bvh):
is_not_climbing = True
segment_vec = next_co - last_co
#TEST COLLISION
ray_hit, ray_normal, ray_face, ray_distance = bvh.ray_cast(last_co, segment_vec, segment_vec.length)
if ray_hit:
is_not_climbing = False
mirror = (last_co-ray_hit).reflect(ray_normal)
mirror += ray_hit
reflected = ray_hit-mirror
reflected.length += opt.collision_margin
reflected += mirror
coll_vec = reflected - last_co
if coll_vec.dot(ray_normal) > 0:
coll_vec.length = opt.scale
next_co = last_co+coll_vec
#PUSH TO COLLISION MARGIN
near_hit_next, near_normal_next, near_face_next, near_distance_next = bvh.find_nearest(next_co)
if near_distance_next < opt.collision_margin:
is_not_climbing = False
next_co += near_normal_next * (opt.collision_margin - near_distance_next)
return next_co, is_not_climbing
#################################################################
#### PARALLEL UPDATE FOR EACH BRANCH <--> SPLINE
@aio.coroutine
def grow_branch(context, branchidx, ivy, bvh=None):
'''
Should have two branches maybe.
Test if only the next coordinate is missing:
if yes only calculate that one.
Reduce computation per frame update
if not recalc spline points from start
as is done now
'''
opt = ivy.ivy
seed_val = opt.seed + branchidx + 1
seed(seed_val)
noise.seed_set(seed_val)
### GET BRANCH-NUMSTEPS FOR THIS FRAME
if opt.animated:
#this is fixed steps along animation range
anim_frames_total = opt.end - opt.start
anim_frame_current = context.scene.frame_current - opt.start
numsteps = int((anim_frame_current / anim_frames_total) * opt.fixed_steps)
else:
numsteps = opt.fixed_steps
### CUTOFF NUMSTEPS
cutoff = random()
if opt.steps_random_cutoff <= cutoff:
#cut this one off
cutoffamount = (1 - cutoff) * opt.cutoffamount
cutoff += cutoffamount
numsteps = int(cutoff * numsteps)
uvec = noise.random_unit_vector()
start_co = Vector((uvec.x * opt.root_area.x,
uvec.y * opt.root_area.y,
uvec.z * opt.root_area.z))
coords = [start_co]
#free = [True]
def recalc_all():
freefloatinglength = 0
for step in range(numsteps):
last_co = coords[-1]
vec_grow = growvec(opt, coords, bvh, freefloatinglength)
next_co = last_co + vec_grow
if opt.has_collider:
next_co, is_free = collision(opt, last_co, next_co, bvh)
if is_free:
freefloatinglength += (last_co - next_co).length
else:
freefloatinglength = 0
else:
freefloatinglength += (last_co - next_co).length
coords.append(next_co)
recalc_all()
return coords
def get_collider_bvh(context, ivy):
opt = ivy.ivy
if opt.has_collider:
#collider in ivy space returns theoretically the
#correct mesh. But somehow rotations still mock
#up the collsions.
bm = collider_in_ivy_space(context, ivy)
bvh = BVHTree()
bvh = bvh.FromBMesh(bm)
#from object does not take transforms into account
#bvh = bvh.FromObject(context.scene.objects[opt.collider], context.scene)
return bvh
else:
return None
#### PARALLEL UPDATE FOR EACH IVY
@aio.coroutine
def update_ivy(context, ivy):
#dspl.clear()
#dspl.set_transform(ivy.matrix_world)
if not ensure_integrity(context, ivy): return
printd('UPDATING "%s" Frame: %d' %(ivy.name, context.scene.frame_current))
opt = ivy.ivy
bvh = get_collider_bvh(context, ivy)
branch_tasks = [aio.async(grow_branch(context, branchidx, ivy, bvh=bvh)) \
for branchidx in range(opt.num_roots)]
branches = yield from aio.gather(*branch_tasks)
create_splines(ivy, branches)
#### INEGRITY CHECK FOR OPTIONS
def ensure_integrity(context, ivy):
opt = ivy.ivy
#Check Integrity of end frame of ivy
if opt.end <= opt.start:
opt.end = opt.start + 1
#Check validity of collider mesh
if opt.collider:
if not opt.collider in context.scene.objects:
opt.has_collider = False
elif context.scene.objects[opt.collider].type != 'MESH':
opt.has_collider = False
else:
opt.has_collider = True
else:
opt.has_collider=False
#Check if inside of animation range
if opt.animated:
if context.scene.frame_current < opt.start:
ivy.data.splines.clear()
return False
elif context.scene.frame_current > opt.end:
return False
#All is well
return True
#################################################################
### FRAME CHANGE UPDATE HANDLER
#################################################################
@persistent
def ivy_update(scene):
context = bpy.context
if not context.mode == 'OBJECT':
return
ivies = [ob for ob in scene.objects if ob.ivy.use_as_ivy]
loop = aio.new_event_loop()
aio.set_event_loop(loop)
loop = aio.get_event_loop()
tasks = [aio.async(update_ivy(context, ivy)) \
for ivy in ivies]
if tasks:
loop.run_until_complete(aio.wait(tasks))
loop.close()
context.scene.update()
#### NO ANIMATION --> FIXED STEPSIZE
def non_animated_update(self, context):
if not context.mode == 'OBJECT':
return
ivies = [context.scene.objects.active]
loop = aio.new_event_loop()
aio.set_event_loop(loop)
loop = aio.get_event_loop()
tasks = [aio.async(update_ivy(context, ivy)) \
for ivy in ivies]
if tasks:
loop.run_until_complete(aio.wait(tasks))
loop.close()
context.scene.update()
#################################################################
class IvyProperties(PropertyGroup):
has_collider = BoolProperty(
name='has valid collider',
default=False,
options={'HIDDEN'},
description='__internal__')
added_as_ivy = BoolProperty(
name='Added as Ivy',
default=False,
options={'HIDDEN'},
description='__internal__')
#GENERAL PROPERTIES
use_as_ivy = BoolProperty(
name='Ivy',
default=False,
update=update_func,
description='Update Ivy on frame change and when tweaking settings.\n'
'Turn off when no updates are needed ot save CPU-cycles.\n'
'WARNING: Destroys/Re-Creates Curve Geometry.')
num_roots = IntProperty(
name='Root Count',
default=3,
min=1, soft_min=1,
update=update_func,
#set=update_on_set, #no good implementation found
description='Number of root branches to grow')
root_area = FloatVectorProperty(
name='Root Area',
size=3,
subtype='XYZ',
default=(0.0, 0.0, 0.0),
min=0,
update=update_func,
description='X-Y-Z radius of sphere from where the branches start')
scale = FloatProperty(
name='Scale',
default=0.05,
precision=3,
min=0.00001, soft_min=0.00001,
update=update_func,
description='Ivy scale.\n'
'The desired distance between curve points.')
seed = IntProperty(
name='Seed',
default=1,
min=0, soft_min=0,
update=update_func,
description='Random Seed')
#COLLIDER
collider = StringProperty(
name='Collider',
default='',
update=update_func,
description='Mesh Collider object Name.\n'
'IMPORTANT: Apply Rotation of collider to work reliably.\n')
collision_margin = FloatProperty(
name='Collision Margin',
default=0.03,
min=0, soft_min=0,
update=update_func,
description='Distance to Colidder after Collision')
#GROWTH VECTOR PROPS
scale_random = FloatProperty(
name='Random',
default=0.40,
min=0, soft_min=0,
update=update_func,
description='Random ivy scale.\n'
'More random --> more random :)')
scale_gravity = FloatProperty(
name='Gravity',
default=0.10,
min=0, soft_min=0,
update=update_func,
description='Gravity influence.\n'
'Zero disables gravity.')
stiffness_gravity = FloatProperty(
name='Gravity stiffness',
default=0.5,
min=0, soft_min=0,
update=update_func,
description='Free floating distance until gravity is at full influence.\n'
'Zero disables gravity.')
scale_up = FloatProperty(
name='Up',
default=0.2,
min=0, soft_min=0,
update=update_func,
description='Scale of up-vector force (in ivy-local-space)')
stiffness_up = FloatProperty(
name='Up stiffness',
default=0,
min=0, soft_min=0,
update=update_func,
description='Free floating distance until Up-Force is at full influence.\n'
'Zero disables stiffnes (uniform up force over all).')
scale_straight = FloatProperty(
name='Straight',
default=1,
min=0, soft_min=0,
update=update_func,
description='Straight ivy scale.\n'
'The "straighter" the less wiggly.')
#ADHESION
scale_adhesion = FloatProperty(
name='Adhesion Strength',
default=1,
min=0, soft_min=0,
#max=1,
update=update_func,
description='Adhesion scale.\n'
'The adhesion Properties can be very dependent on the\n'
'character of the mesh (sharp corners, non.manifold, ...)')
adhesion_angle_influence = FloatProperty(
name='Adhesion angle',
default=1,
#min=0, soft_min=0,
#max=1, soft_max=1,
update=update_func,
description='Deals mainly with corners and open collider mesh edges.\n'
'At negative values adhesion is inverted on sharp corners/open boundaries.\n'
'With positive values the branch is "pulled" around the corner.\n'
'Still backfacing faces never apply adhesion to the branch.')
adhesion_floating_influence = FloatProperty(
name='Adhesion floating Influence',
default=1,
#min=-1, soft_min=-1,
#max=1, soft_max=1,
update=update_func,
description='Above zero: increase adhesion at small floating length.\n'
'Below zero: invert adhesion at small floating length (push from surface).\n'
'zero: disabled\n'
'Adhesion is scaled towards zero at Adhesion floating length')
adhesion_floating_length = FloatProperty(
name='Adhesion floating length',
default=1,
min=0, soft_min=0,
#max=1, soft_max=1,
update=update_func,
description='Length setting for Adhesion floating Influence.\n'
'The length of a branch from either the root or the last collision.')
max_dist_adhesion = FloatProperty(
name='Adhesion Max Distance',
default=1,
min=0, soft_min=0,
update=update_func,
description='Adhesion Max Distance. 0 disables.\n'
'The maximum distance to the collider mesh where adhesion applies force.')
#ANIMATION
animated = BoolProperty(
name='Animated',
default=False,
update=update_func,
description='Use start-end for animation of ivy.')
steps = IntProperty(
name='Steps',
default=1,
min=1, soft_min=1,
update=update_func,
description='Steps per Branch')
start = IntProperty(
name='Start Frame',
default=1,
#min=1, soft_min=0,
update=update_func,
description='Start Frame of Ivy growth')
end = IntProperty(
name='End Frame',
default=100,
#min=1, soft_min=0,
update=update_func_endframe,
description='End Frame of Ivy growth')
#BRANCHPROPERTIES
fixed_steps = IntProperty(
name='Fixed Steps',
default=100,
min=1, soft_min=1,
#update=update_func,
update=non_animated_update,
description='Steps of Ivy growth')
steps_random_cutoff = FloatProperty(
name='Random Cutoff',
subtype='FACTOR',
default=1,
min=0, soft_min=0,
max=1, soft_max=1,
update=update_func,
description='Probability of branches to reach final step-length.')
cutoffamount = FloatProperty(
name='Cutoff Amount',
subtype='FACTOR',
default=0.5,
min=0, soft_min=0,
max=1, soft_max=1,
update=update_func,
description='Factor of cutoff.')
#################################################################
class IvyPanel(Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "modifier"
bl_label = 'Animated Ivy'
#bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
ob = context.object
return ob and ob.type == 'CURVE' and ob.ivy.added_as_ivy
def draw_header(self, context):
layout = self.layout
layout.prop(context.object.ivy, 'use_as_ivy', text='', icon='PARTICLE_PATH')
def draw(self, context):
scene = context.scene
ob = scene.objects.active
opt = ob.ivy
layout = self.layout
layout.active = opt.use_as_ivy
col = layout.column(align=True)
row = col.row(align=True)
row.prop(opt, 'seed')
row.prop(opt, 'num_roots')
col.separator()
#col.prop(opt, 'collider', icon='OBJECT_DATA')
col.prop_search(opt, "collider", scene, "objects", text="Collider")
if opt.has_collider:
col.prop(opt, 'collision_margin')
col.separator()
col.prop(opt.id_data.data, 'bevel_depth')
col.separator()
col.prop(opt, 'scale')
col.prop(opt, 'scale_up')
col.prop(opt, 'stiffness_up')
col.prop(opt, 'scale_straight')
col.prop(opt, 'scale_random')
col.prop(opt, 'scale_gravity')
col.prop(opt, 'stiffness_gravity')
if opt.has_collider:
col.separator()
col.prop(opt, 'scale_adhesion')
col.prop(opt, 'adhesion_angle_influence')
col.prop(opt, 'max_dist_adhesion')
col.prop(opt, 'adhesion_floating_influence')
col.prop(opt, 'adhesion_floating_length')
col.separator()
row=col.row()
row.prop(opt, 'root_area')
col.separator()
row = col.row(align=True)
row.prop(opt, 'fixed_steps', text='Steps')
row.prop(opt, 'steps_random_cutoff')
row.prop(opt, 'cutoffamount')
col.separator()
col.prop(opt, 'animated')
if opt.animated:
row = col.row(align=True)
row.active = opt.animated
row.prop(opt, 'start')
row.prop(opt, 'end')
col.separator()
col.operator('curve.add_leafs', icon='PARTICLE_POINT')
def add_animated_ivy(self, context):
sel = context.object
collider = ''
if sel:
if sel.type == 'MESH':
collider = sel.name
bpy.ops.curve.primitive_bezier_curve_add()
ivy = context.scene.objects.active
ivy.name = 'Ivy'
ivy.data.name = ivy.name
ivy.data.fill_mode = 'FULL'
ivy.ivy.use_as_ivy = True
ivy.ivy.added_as_ivy = True
ivy.ivy.collider = collider
bpy.ops.object.modifier_add(type='SUBSURF')
mod = ivy.modifiers[-1]
mod.levels = 0
mod.show_only_control_edges = True
mod.show_expanded = False
class OBJECT_OT_add_growing_ivy(Operator):
"""Create a growing Ivy.
Selected Mesh Object acts as collider.
Options in the Modifier Panel."""
bl_idname = "curve.add_animated_ivy"
bl_label = "Add Animated Ivy"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.mode == 'OBJECT'
def execute(self, context):
add_animated_ivy(self, context)
return {'FINISHED'}
###########################################################
def register():
bpy.utils.register_class(OBJECT_OT_add_growing_ivy)
bpy.utils.register_class(IvyPanel)
bpy.utils.register_class(IvyProperties)
bpy.types.Object.ivy = PointerProperty(type=IvyProperties)
bpy.app.handlers.frame_change_post.append(ivy_update)
def unregister():
bpy.utils.unregister_class(OBJECT_OT_add_growing_ivy)
bpy.utils.unregister_class(IvyPanel)
bpy.utils.unregister_class(IvyProperties)
bpy.app.handlers.frame_change_post.remove(ivy_update)
del(bpy.types.Object.ivy)
if __name__ == "__main__":
register()