Mesh Optimizer: sibling StaticMesh duplicate remover (UE 5.7)
Editor plugin that detects geometrically-identical sibling StaticMeshes across a level, rebases each placement onto one canonical mesh with a corrected transform (W' = D * W, verified by exact vertex matching), and can collapse groups into HISM. Native Slate tool panel + BlueprintCallable UOptimizerSubsystem. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
35
Source/OptimizerEditor/Private/OptimizerMatcher.h
Normal file
35
Source/OptimizerEditor/Private/OptimizerMatcher.h
Normal file
@ -0,0 +1,35 @@
|
||||
// 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);
|
||||
}
|
||||
Reference in New Issue
Block a user