Skip to content

Commit a450f2c

Browse files
committed
Fixed rare case of edge-to-edge contact where zero as result is undesirable
Also a small fix for the last commit in the mass calculation for surfaces. Bumping version number due to recent changes to the calculation of surface mass.
1 parent 822af0b commit a450f2c

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

kk_bullet_constraints_builder.zip

121 Bytes
Binary file not shown.

kk_bullet_constraints_builder/builder_prep.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -888,10 +888,15 @@ def calculateContactAreaBasedOnBoundaryBoxesForPair(objA, objB, sDistFallb, qNon
888888

889889
if not qAccurate or qSkipConnect or sDistFallb:
890890
### Calculate simple overlap of boundary boxes for contact area calculation (project along all axis')
891-
overlapX = max(0, min(bbAMax[0],bbBMax[0]) -max(bbAMin[0],bbBMin[0]))
892-
overlapY = max(0, min(bbAMax[1],bbBMax[1]) -max(bbAMin[1],bbBMin[1]))
893-
overlapZ = max(0, min(bbAMax[2],bbBMax[2]) -max(bbAMin[2],bbBMin[2]))
894-
891+
# Include minimumContactArea for rare cases of edge-to-edge contact where we don't want to get zero as result
892+
bbAMin_ = Vector((bbAMin[0]-minimumContactArea, bbAMin[1]-minimumContactArea, bbAMin[2]-minimumContactArea))
893+
bbAMax_ = Vector((bbAMax[0]+minimumContactArea, bbAMax[1]+minimumContactArea, bbAMax[2]+minimumContactArea))
894+
bbBMin_ = Vector((bbBMin[0]-minimumContactArea, bbBMin[1]-minimumContactArea, bbBMin[2]-minimumContactArea))
895+
bbBMax_ = Vector((bbBMax[0]+minimumContactArea, bbBMax[1]+minimumContactArea, bbBMax[2]+minimumContactArea))
896+
overlapX = max(0, min(bbAMax_[0],bbBMax_[0]) -max(bbAMin_[0],bbBMin_[0]))
897+
overlapY = max(0, min(bbAMax_[1],bbBMax_[1]) -max(bbAMin_[1],bbBMin_[1]))
898+
overlapZ = max(0, min(bbAMax_[2],bbBMax_[2]) -max(bbAMin_[2],bbBMin_[2]))
899+
895900
if not qSkipConnect or props.surfaceForced:
896901

897902
### Calculate area based on either the sum of all axis surfaces...
@@ -1877,15 +1882,14 @@ def calculateMass(scene, objs, objsEGrp, childObjs):
18771882
if obj != None:
18781883
if "bcb_child" in obj.keys():
18791884
obj = scene.objects[obj["bcb_child"]]
1880-
if (props.surfaceForced == 0 or props.surfaceThickness == 0) and (props.surfaceThickness == 0 or obj not in objsNonMan):
1881-
obj.select = 1
1882-
objsSelected.append(obj)
1883-
# Temporarily revert element scaling for mass calculation
1884-
if qScale:
1885-
if scale != 0 and scale != 1:
1886-
obj.scale /= scale
1887-
objsTotal.append(obj)
1888-
objsScale.append(scale)
1885+
obj.select = 1
1886+
objsSelected.append(obj)
1887+
# Temporarily revert element scaling for mass calculation
1888+
if qScale:
1889+
if scale != 0 and scale != 1:
1890+
obj.scale /= scale
1891+
objsTotal.append(obj)
1892+
objsScale.append(scale)
18891893

18901894
### Calculating and applying material masses based on volume
18911895
materialPreset = elemGrp[EGSidxMatP]

kk_bullet_constraints_builder/global_vars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
################################################################################
3636

3737
### Vars:
38-
bcb_version = (3, 6, 3)
38+
bcb_version = (3, 6, 4)
3939

4040
### Customizable element group presets
4141
presets = [

0 commit comments

Comments
 (0)