From 8e0050f06530b9b390bbd1246f6a86cfa1e136a0 Mon Sep 17 00:00:00 2001 From: "YITSUSE, Masami" Date: Tue, 23 Jun 2026 15:59:18 +0900 Subject: [PATCH] revert(player): remove instance nesting depth guard Drop the MAX_INSTANCE_DEPTH (16) cyclic/runaway-nesting guard added in 9e6d469. Per review, a cyclic Instance reference (A -> B -> A) is an authoring mistake in the data, not something the player should guard against, so the player no longer caps Instance nesting depth. Removes `_instance_depth`, `MAX_INSTANCE_DEPTH`, the setInstanceDepth/getInstanceDepth accessors, the depth check and the warning skip in `_setup_instance_children`, and the child depth propagation. Intentionally diverges from the Unity player's MaxInstanceDepth. The audio signal from 9e6d469 is unrelated and kept. --- ss_player/ss_internal_player.cpp | 15 +-------------- ss_player/ss_internal_player.h | 11 ----------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/ss_player/ss_internal_player.cpp b/ss_player/ss_internal_player.cpp index d84c38c..e51d7cf 100644 --- a/ss_player/ss_internal_player.cpp +++ b/ss_player/ss_internal_player.cpp @@ -1355,15 +1355,6 @@ void SsInternalPlayer::_setup_instance_children() { auto pt = p->part_type_as_PartTypeInstance(); if (!pt) continue; - // Cyclic / runaway-nesting guard: instance children live one level - // deeper than this player. Refuse to descend past MAX_INSTANCE_DEPTH so - // a cyclic reference (A → B → A authoring mistake) can't recurse until - // the stack overflows on load. - if (_instance_depth + 1 >= MAX_INSTANCE_DEPTH) { - WARN_PRINT(vformat("[SS] instance part %d: nesting exceeded %d levels; skipping to guard against cyclic references", i, MAX_INSTANCE_DEPTH)); - continue; - } - String pack_name = pt->ref_anime_pack() ? String::utf8(pt->ref_anime_pack()->c_str()) : String(); String anim_name = pt->ref_anime_name() ? String::utf8(pt->ref_anime_name()->c_str()) : String(); uint32_t pack_name_hash = pt->ref_anime_pack_hash(); @@ -1378,7 +1369,6 @@ void SsInternalPlayer::_setup_instance_children() { SsInternalPlayer* child = memnew(SsInternalPlayer); child->setParentDriven(true); - child->setInstanceDepth(_instance_depth + 1); child->setSubFrameEnabled(_sub_frame_enabled); // Hand the child the SSAB that actually contains the referenced // animation — may be `_ssabRes` itself or an external sibling. @@ -2608,10 +2598,7 @@ void SsInternalPlayer::_fetchAnimation() { } // Recursive setup — instance children also populate their own - // `_instance_children`, so nested Instance parts are supported. Cross-SSAB - // cycles (A → B → A authoring mistakes) are bounded by MAX_INSTANCE_DEPTH: - // `_setup_instance_children` stops spawning children past that depth (with - // a warning) instead of recursing until the stack overflows on load. + // `_instance_children`, so nested Instance parts are supported. _setup_instance_children(); _setup_effect_slots(); diff --git a/ss_player/ss_internal_player.h b/ss_player/ss_internal_player.h index de72fff..0ce2ead 100644 --- a/ss_player/ss_internal_player.h +++ b/ss_player/ss_internal_player.h @@ -161,14 +161,6 @@ class SsInternalPlayer { void setParentDriven(bool p_enabled); bool isParentDriven() const { return _parent_driven; } - // Nesting depth within an Instance-part chain (0 = the root player the host - // owns). `_setup_instance_children` sets each spawned child to parent depth - // + 1 and refuses to descend past `MAX_INSTANCE_DEPTH`, guarding against - // cyclic Instance references (A → B → A authoring mistakes) that would - // otherwise recurse until the stack overflows on load. - void setInstanceDepth(int p_depth) { _instance_depth = p_depth; } - int getInstanceDepth() const { return _instance_depth; } - // Per-tick update (in seconds; the host typically passes // `process_delta_time`). No-op when paused or in instance-child mode. void update(float delta_seconds); @@ -328,9 +320,6 @@ class SsInternalPlayer { float _speed_rate = 1.0f; bool _sub_frame_enabled = false; bool _parent_driven = false; - int _instance_depth = 0; - // Hard cap on Instance-part nesting depth; see `setInstanceDepth`. - static constexpr int MAX_INSTANCE_DEPTH = 16; SsPlayerEventSink* _event_sink = nullptr;