更新自研插件

This commit is contained in:
2026-10-04 19:27:54 +08:00
parent 604612baac
commit a17800db9c
7 changed files with 275 additions and 147 deletions
-36
View File
@@ -60,9 +60,6 @@ enum BodyType {
CHARACTER, ## CharacterBody3D - player/NPC.
}
const SHAPE_TYPE_NAMES: PackedStringArray = [
"convex_hull", "trimesh", "box", "sphere", "capsule", "cylinder",
]
const BODY_TYPE_NAMES: PackedStringArray = [
"static", "rigid", "area", "character",
]
@@ -119,15 +116,6 @@ static func is_imported_model(path: String) -> bool:
return FileAccess.file_exists(path + ".import")
## True when `node` is a root node instantiated directly from a model file.
static func is_model_instance(node: Node) -> bool:
if node == null or not is_instance_valid(node):
return false
if node.scene_file_path.is_empty():
return false
return is_imported_model(node.scene_file_path)
# ---------------------------------------------------------------------------
# Collision generation
# ---------------------------------------------------------------------------
@@ -612,27 +600,3 @@ static func _cylinder_shape(mi: MeshInstance3D, to_local: Transform3D) -> Cylind
shape.height = h
shape.set_meta(META_SHAPE_OFFSET, box.get_center())
return shape
# ---------------------------------------------------------------------------
# Diagnostics
# ---------------------------------------------------------------------------
## A one-line description of the collision under `root`, for log output.
static func describe_collision(root: Node) -> String:
var shapes := count_shapes(root)
if shapes == 0:
return "no collision"
var kinds: Dictionary = {}
var stack: Array[Node] = [root]
while not stack.is_empty():
var n: Node = stack.pop_back()
if n is CollisionShape3D and (n as CollisionShape3D).shape != null:
var k := (n as CollisionShape3D).shape.get_class()
kinds[k] = int(kinds.get(k, 0)) + 1
for c in n.get_children():
stack.append(c)
var parts: Array[String] = []
for k in kinds:
parts.append("%s x%d" % [k, kinds[k]])
return "%d shape(s): %s" % [shapes, ", ".join(parts)]