Skip to content

Commit

Permalink
Merge pull request #23 from takahiro0327/fix_gcalloc
Browse files Browse the repository at this point in the history
Reduce gc alloc
  • Loading branch information
Sauceke authored Feb 18, 2024
2 parents 9624299 + ec5a473 commit 7fbc5dc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions KK_SexFaces/FBSExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ private static void AddLopsided(this FBSCtrlMouth mouthCtrl, MouthPattern basePt
}
var meshCtrl = fbs.GetSkinnedMeshRenderer();
var mesh = meshCtrl.sharedMesh;
int vertCount = mesh.vertexCount;
var vertices = mesh.vertices;
int vertCount = vertices.Length;
var deltaVertsOpen = new Vector3[vertCount];
var deltaVertsClosed = new Vector3[vertCount];
var deltaNorms = new Vector3[vertCount];
var deltaTans = new Vector3[vertCount];
float halfWidth = mesh.vertices.Max(_ => _.x);
float halfWidth = vertices.Max(_ => _.x);
int openPtn = fbs.PtnSet[(int)basePtn].Open;
int closedPtn = fbs.PtnSet[(int)basePtn].Close;
mesh.GetBlendShapeFrameVertices(openPtn, 0, deltaVertsOpen, deltaNorms, deltaTans);
Expand All @@ -85,7 +86,7 @@ private static void AddLopsided(this FBSCtrlMouth mouthCtrl, MouthPattern basePt
var deltaVertsLopsided = new Vector3[vertCount];
for (int i = 0; i < vertCount; i++)
{
float relativeX = Mathf.InverseLerp(-halfWidth, halfWidth, mesh.vertices[i].x);
float relativeX = Mathf.InverseLerp(-halfWidth, halfWidth, vertices[i].x);
float blend = Sigmoid(relativeX);
if (leanRight)
{
Expand Down

0 comments on commit 7fbc5dc

Please sign in to comment.