Skip to content

Commit

Permalink
chore: add MeshInfo2 system
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Jan 27, 2023
1 parent 5c08225 commit 36716dd
Show file tree
Hide file tree
Showing 3 changed files with 455 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Editor/Processors/SkinnedMeshes/EditSkinnedMeshProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal abstract class EditSkinnedMeshProcessor<TComponent> : IEditSkinnedMeshP
public abstract int ProcessOrder { get; }
public IEnumerable<SkinnedMeshRenderer> Dependencies => Array.Empty<SkinnedMeshRenderer>();
protected TComponent Component { get; }
[Obsolete]
public SkinnedMeshRenderer Target { get; }

EditSkinnedMeshComponent IEditSkinnedMeshProcessor.Component => Component;
Expand All @@ -23,6 +24,26 @@ protected EditSkinnedMeshProcessor(TComponent component)
}

public abstract void Process(OptimizerSession session);

public virtual void Process(OptimizerSession session, MeshInfo2 target)
{
target.WriteToMesh(session.MayInstantiate(Target.sharedMesh));
Process(session);
session.Destroy(Component);
target.ReadSkinnedMesh(Target.sharedMesh);
}

protected void ProcessWithNew(OptimizerSession session)
{
var target = new MeshInfo2(Target);
Process(session, target);
target.WriteToMesh(session.MayInstantiate(Target.sharedMesh));
for (var i = 0; i < target.BlendShapes.Length; i++)
Target.SetBlendShapeWeight(i, target.BlendShapes[i].weight);
Target.sharedMaterials = target.SharedMaterials;
Target.bones = target.Bones;
}

public abstract IMeshInfoComputer GetComputer(IMeshInfoComputer upstream);

protected bool Equals(EditSkinnedMeshProcessor<TComponent> other) => Component == other.Component;
Expand Down
Loading

0 comments on commit 36716dd

Please sign in to comment.