You've already forked stocker_helper
Migrated from Stocker project
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import bpy
|
||||
import mathutils
|
||||
|
||||
def calculate_global_bounds(selected_objects):
|
||||
if not selected_objects:
|
||||
print("No objects selected.")
|
||||
return None
|
||||
|
||||
min_x = float('inf')
|
||||
min_y = float('inf')
|
||||
min_z = float('inf')
|
||||
max_x = float('-inf')
|
||||
max_y = float('-inf')
|
||||
max_z = float('-inf')
|
||||
|
||||
for obj in selected_objects:
|
||||
if obj.type != 'MESH':
|
||||
continue
|
||||
|
||||
# Transform local bounding box corners to world space
|
||||
matrix = obj.matrix_all_world = obj.matrix_world
|
||||
for corner in obj.bound_box:
|
||||
world_corner = matrix @ mathutils.Vector(corner)
|
||||
|
||||
min_x = min(min_x, world_corner.x)
|
||||
min_y = min(min_y, world_corner.y)
|
||||
min_z = min(min_z, world_corner.z)
|
||||
max_x = max(max_x, world_corner.x)
|
||||
max_y = max(max_y, world_corner.y)
|
||||
max_z = max(max_z, world_corner.z)
|
||||
|
||||
if min_x == float('inf'):
|
||||
print("No valid mesh objects found in selection.")
|
||||
return None
|
||||
|
||||
return {
|
||||
'min': (min_x, min_y, min_z),
|
||||
'max': (max_x, max_y, max_z),
|
||||
'dimensions': (max_x - min_x, max_y - min_y, max_z - min_z),
|
||||
'target_origin': (max_x, min_y, min_z)
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Phase 1: Logic verification script loaded.")
|
||||
Reference in New Issue
Block a user