// Copyright IHY. #pragma once #include "CoreMinimal.h" #include "OptimizerTypes.h" #include "OptimizerGeometry.h" /** * Recovered rigid (optionally mirrored/scaled) delta that maps CANONICAL-local geometry onto * MEMBER(sibling)-local geometry. Stored as a UE row-vector matrix: v_member = v_canon * CanonToMember. * This is exactly the D in the corrective formula W' = D * W. */ struct FOptDelta { bool bValid = false; bool bIdentity = false; // delta is (within tolerance) identity -> swap mesh, keep transform bool bMirrored = false; // recovered rotation is improper (det < 0) -> negative-scale instance bool bScaled = false; // uniform scale != 1 folded in double Scale = 1.0; double MaxDev = 0.0; // worst per-vertex deviation under the delta, cm double Rms = 0.0; FMatrix CanonToMember = FMatrix::Identity; }; namespace OptimizerMatcher { /** Cheap bucket test: are these two fingerprints compatible enough to attempt recovery? */ bool FingerprintCompatible(const FOptMeshGeom& A, const FOptMeshGeom& B, const FOptimizerScanSettings& Settings); /** * Recover the delta mapping canonical-local (A) onto member-local (B). Both A.Positions and * B.Positions must be populated. Returns false if no candidate passes verification. */ bool RecoverDelta(const FOptMeshGeom& A, const FOptMeshGeom& B, const FOptimizerScanSettings& Settings, FOptDelta& Out); }