Skip to content

Commit 75a038e

Browse files
committed
Minor cleanups after the recent live load fix
No functional change.
1 parent 73c71f6 commit 75a038e

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

kk_bullet_constraints_builder.zip

-162 Bytes
Binary file not shown.

kk_bullet_constraints_builder/builder_prep.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,19 +2011,19 @@ def calculateMass(scene, objs, objsEGrp, childObjs):
20112011

20122012
objsSelected = []
20132013
for k in range(len(objs)):
2014-
obj = objs[k]
2015-
if obj != None and obj.rigid_body != None:
2016-
CT = elemGrps[objsEGrp[k]][EGSidxCTyp]
2017-
if CT == 0:
2018-
# The foundation buffer objects need a large mass so they won't pushed away
2019-
materialDensity = elemGrp[EGSidxDens]
2020-
if materialDensity > 1: obj.rigid_body.mass = materialDensity
2021-
else: obj.rigid_body.mass = 1000 # Backward compatibility for older settings
2022-
else:
2023-
try: scale = elemGrps[objsEGrp[k]][EGSidxScal] # Try in case elemGrps is from an old BCB version
2024-
except: qScale = 0
2025-
else: qScale = 1
2026-
if j == objsEGrp[k]:
2014+
if objsEGrp[k] == j: # If object is in current element group
2015+
obj = objs[k]
2016+
if obj != None and obj.rigid_body != None:
2017+
CT = elemGrps[j][EGSidxCTyp]
2018+
if CT == 0:
2019+
# The foundation buffer objects need a large mass so they won't pushed away
2020+
materialDensity = elemGrp[EGSidxDens]
2021+
if materialDensity > 1: obj.rigid_body.mass = materialDensity
2022+
else: obj.rigid_body.mass = 1000 # Backward compatibility for older settings
2023+
else:
2024+
try: scale = elemGrps[j][EGSidxScal] # Try in case elemGrps is from an old BCB version
2025+
except: qScale = 0
2026+
else: qScale = 1
20272027
if obj != None:
20282028
if "bcb_child" in obj.keys():
20292029
obj = scene.objects[obj["bcb_child"]]
@@ -2049,9 +2049,6 @@ def calculateMass(scene, objs, objsEGrp, childObjs):
20492049

20502050
### Calculating and applying material masses based on surface area * thickness
20512051
if (props.surfaceForced and props.surfaceThickness) or (props.surfaceThickness and len(objsNonMan)):
2052-
# Deselect all objects
2053-
bpy.ops.object.select_all(action='DESELECT')
2054-
20552052
# Find out density of the element group
20562053
if not materialDensity:
20572054
materialPreset = elemGrp[EGSidxMatP]
@@ -2070,7 +2067,7 @@ def calculateMass(scene, objs, objsEGrp, childObjs):
20702067
for n in range(len(objsNonMan)):
20712068
obj = objsNonMan[n]
20722069
k = objsIndex[obj.name]
2073-
if j == objsEGrp[k]:
2070+
if objsEGrp[k] == j: # If object is in current element group
20742071
# Calculate object surface area and volume
20752072
me = obj.data
20762073
area = sum(f.area for f in me.polygons)
@@ -2118,7 +2115,7 @@ def calculateMass(scene, objs, objsEGrp, childObjs):
21182115
except:
21192116
try: groupsArea[group.name] = obj["Floor Area"]
21202117
except: pass
2121-
for groupName in groupsMass.keys():
2118+
for groupName in sorted(groupsMass.keys()):
21222119
try: mass = groupsMass[groupName]
21232120
except: mass = 0
21242121
try: area = groupsArea[groupName]

0 commit comments

Comments
 (0)