Skip to content

Commit 1a5b058

Browse files
committed
Fixed incorrect centroids when using the Displacement Correction feature
Also added an optimization: disabling dynamic paint after simulation improves animation playback speed.
1 parent 12483db commit 1a5b058

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

kk_bullet_constraints_builder.zip

115 Bytes
Binary file not shown.

kk_bullet_constraints_builder/builder_prep.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,18 +1289,21 @@ def applyDisplacementCorrection(objs, objsEGrp, connectsPair, connectsLoc):
12891289
grpName = elemGrp[EGSidxName]
12901290
for obj in grpsObjs[grpName]:
12911291
inv_matrix = obj.matrix_world.inverted()
1292+
vIdxLast = vIdx
12921293
for vert in obj.data.vertices:
12931294
current_world_loc = obj.matrix_world *vert.co
12941295
corrected_world_loc = current_world_loc -Vector(vLocData[vIdx])
12951296
local_corrected_loc = inv_matrix * corrected_world_loc
12961297
vert.co = local_corrected_loc
12971298
vIdx += 1
1299+
if vIdxLast != vIdx:
1300+
obj.select = 1
12981301

12991302
# If changes have been made
13001303
if vIdx > 0:
13011304
# Set object centers to geometry origin (again after prepareObjects())
13021305
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')
1303-
1306+
13041307
### Apply corrections also on connection locations
13051308
connectsPair_iter = iter(connectsPair)
13061309
connectsLoc_iter = iter(connectsLoc)

kk_bullet_constraints_builder/monitor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,12 @@ def monitor_freeBuffers_fm(scene):
17821782
print("\rWarning: Element has lost its constraint references or the corresponding empties their constraint properties respectively, rebuilding constraints is recommended.")
17831783
print("(%s)" %const.name)
17841784

1785+
### Disable Dynamic Paint modifier after baking for a playback performance boost
1786+
for mod in objFM.modifiers:
1787+
if "Dynamic Paint" in mod.name:
1788+
mod.show_render = False
1789+
mod.show_viewport = False
1790+
17851791
### Damping Region - revert RBs to original dampings
17861792
if "bcb_damps" in bpy.app.driver_namespace:
17871793
### Get damping region object
@@ -1817,7 +1823,7 @@ def monitor_freeBuffers_fm(scene):
18171823
# Clear broken connections properties
18181824
try: del bpy.app.driver_namespace["bcb_progrWeakBroken"]
18191825
except: pass
1820-
1826+
18211827
################################################################################
18221828

18231829
def monitor_freeBuffers_both(scene):

0 commit comments

Comments
 (0)