1.增加碰撞面板
This commit is contained in:
parent
9a997c4036
commit
39a52b3953
File diff suppressed because one or more lines are too long
@ -325,18 +325,29 @@ class CollisionManager:
|
||||
return CollisionSphere(center, kwargs.get('radius', radius))
|
||||
|
||||
elif shape_type == 'box':
|
||||
# 创建包围盒
|
||||
min_point = bounds.getMin()
|
||||
max_point = bounds.getMax()
|
||||
# 创建自定义尺寸的包围盒
|
||||
width = kwargs.get('width', bounds.getMax().x - bounds.getMin().x)
|
||||
length = kwargs.get('length', bounds.getMax().y - bounds.getMin().y)
|
||||
height = kwargs.get('height', bounds.getMax().z - bounds.getMin().z)
|
||||
|
||||
# 计算盒子的最小和最大点
|
||||
half_width = width / 2
|
||||
half_length = length / 2
|
||||
half_height = height / 2
|
||||
|
||||
min_point = Point3(center.x - half_width, center.y - half_length, center.z - half_height)
|
||||
max_point = Point3(center.x + half_width, center.y + half_length, center.z + half_height)
|
||||
return CollisionBox(min_point, max_point)
|
||||
|
||||
elif shape_type == 'capsule':
|
||||
# 创建胶囊体(适合角色)
|
||||
height = kwargs.get('height', (bounds.getMax().z - bounds.getMin().z))
|
||||
radius = kwargs.get('radius', min(bounds.getRadius() * 0.5, height * 0.3))
|
||||
point_a = Point3(center.x, center.y, bounds.getMin().z + radius)
|
||||
point_b = Point3(center.x, center.y, bounds.getMax().z - radius)
|
||||
return CollisionCapsule(point_a, point_b, radius)
|
||||
# 创建自定义参数的胶囊体
|
||||
custom_height = kwargs.get('height', (bounds.getMax().z - bounds.getMin().z))
|
||||
custom_radius = kwargs.get('radius', min(bounds.getRadius() * 0.5, custom_height * 0.3))
|
||||
|
||||
# 计算胶囊体的两个端点
|
||||
point_a = Point3(center.x, center.y, center.z - custom_height/2 + custom_radius)
|
||||
point_b = Point3(center.x, center.y, center.z + custom_height/2 - custom_radius)
|
||||
return CollisionCapsule(point_a, point_b, custom_radius)
|
||||
|
||||
elif shape_type == 'plane':
|
||||
# 创建平面(适合地面、墙面)
|
||||
|
||||
1086
ui/property_panel.py
1086
ui/property_panel.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user