Keep SetWeapon/AttachPart helper attachments across rebinds

Helper attachments made outside the part slots were attached to
PART_MAIN only and dropped whenever the parts were rebound (LOD level
change, shape change, slot update). They are now recorded on the actor,
attached to the drawn instance and re-attached after the slots. A slot
taking the same bone drops the helper (last writer wins, as before);
SetRace/SetModel clear them. LODs missing a helper's bone stay on
PART_MAIN.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-12 18:18:14 +09:00
co-authored by Claude Opus 5.5
parent 552f6c7df4
commit c556795ecf
3 changed files with 48 additions and 3 deletions
+16
View File
@@ -844,6 +844,22 @@ int main(int argc, char** argv) {
assert(actor.GetLODAniFPS()==30 && actor.GetLODLevel()==0);
assert(actor.GetDrawModel()->GetFilePath().find("_lod_03.gr2")!=std::string::npos);
assert(!actor.BuildDrawCommands().empty());
// The SetWeapon helper attachment (outside the part slots) follows the LOD instance.
{
auto weaponOnly = ava2::Gr2ModelInstance::Load(weapon_path);
assert(weaponOnly);
std::set<std::string> weaponTextures;
for (const auto& d : weaponOnly->BuildDrawCommands()) weaponTextures.insert(d.texture0);
auto drawsWeapon = [&]() {
for (const auto& d : actor.BuildDrawCommands()) if (weaponTextures.count(d.texture0)) return true;
return false;
};
assert(!weaponTextures.empty() && drawsWeapon() && "weapon must stay attached on the LOD instance");
actor.UpdateLODLevel(0,200,-300,0,0);
assert(actor.GetDrawModel()==actor.GetModel() && drawsWeapon());
actor.UpdateLODLevel(0,200,-4900,2000,0);
assert(actor.GetLODLevel()==0 && drawsWeapon());
}
float lodBone[16];
assert(actor.GetBoneWorldTransform("Bip01 Spine",lodBone));
const auto poseBeforeLod=actor.GetDrawModel()->GetImpl()->GetPoseEvaluationCount();