更新自研插件
This commit is contained in:
@@ -119,16 +119,31 @@ func _inject(model: Node, source: String = "") -> void:
|
||||
if source.is_empty():
|
||||
source = String(model.scene_file_path)
|
||||
|
||||
# Everything below reads `global_transform`, which only resolves inside the
|
||||
# tree. Without this check Godot logs
|
||||
# `Condition "!is_inside_tree()" is true. Returning: Transform3D()` and the
|
||||
# shapes would be baked at the origin.
|
||||
if not model.is_inside_tree():
|
||||
push_warning("[MeshCollider] %s is not in the scene tree; skipped."
|
||||
% model.name)
|
||||
return
|
||||
|
||||
var skip_existing := Settings.get_bool(Settings.KEY_SKIP_EXISTING)
|
||||
if skip_existing and Collider.has_any_collision(model):
|
||||
print("[MeshCollider] %s already has collision; skipped." % model.name)
|
||||
return
|
||||
|
||||
# Built detached on purpose: the editor's undo system owns every tree change
|
||||
# in this plugin, so inserting the body here would mean undoing a change we
|
||||
# had already applied behind undo's back.
|
||||
# Resolve the mesh transforms first, while tree membership is certain, then
|
||||
# build the body from that snapshot. The body itself is built detached on
|
||||
# purpose: the editor's undo system must own every tree change in this
|
||||
# plugin, so inserting it here would mean undoing a change that had already
|
||||
# been applied behind undo's back.
|
||||
var model_xform: Transform3D = (model as Node3D).global_transform
|
||||
var spaces := Collider.collect_mesh_spaces(model, model_xform, skip_existing)
|
||||
var body := Collider.build_collision_body(
|
||||
model,
|
||||
spaces,
|
||||
model_xform,
|
||||
Settings.shape_type(),
|
||||
Settings.body_type(),
|
||||
skip_existing,
|
||||
|
||||
Reference in New Issue
Block a user