perf: eliminate per-frame blendshape string lookups in FaceTrackerClient #40

Merged
lavarius merged 1 commit from fix/blendshape-index-cache into master 2026-03-29 15:14:54 +00:00
Collaborator

Closes #9

Problem

SetBlendshape() was calling mapper.GetBlendshapeName(key) and sharedMesh.GetBlendShapeIndex(name) on every frame for every blendshape — two string lookups per key per frame.

CacheBlendshapeIndices() already built a blendshapeIndexCache at startup, and ApplyFromState() was already doing blendshapeIndexCache.TryGetValue(key, out var index) before calling SetBlendshape() — but then the cached index was discarded and the lookup repeated inside the method.

Fix

Pass the already-resolved index directly into SetBlendshape(int index, ...). The redundant GetBlendshapeName + GetBlendShapeIndex calls are removed entirely.

Closes #9 ## Problem `SetBlendshape()` was calling `mapper.GetBlendshapeName(key)` and `sharedMesh.GetBlendShapeIndex(name)` on every frame for every blendshape — two string lookups per key per frame. `CacheBlendshapeIndices()` already built a `blendshapeIndexCache` at startup, and `ApplyFromState()` was already doing `blendshapeIndexCache.TryGetValue(key, out var index)` before calling `SetBlendshape()` — but then the cached index was discarded and the lookup repeated inside the method. ## Fix Pass the already-resolved `index` directly into `SetBlendshape(int index, ...)`. The redundant `GetBlendshapeName` + `GetBlendShapeIndex` calls are removed entirely.
perf: cache blendshape indices in FaceTrackerClient
All checks were successful
Tests / Run EditMode Tests (pull_request) Successful in 14m29s
f957ea79b6
SetBlendshape() was calling mapper.GetBlendshapeName() and
sharedMesh.GetBlendShapeIndex() on every frame for every blendshape.
The index cache built in CacheBlendshapeIndices() was already being
looked up in ApplyFromState() but the result was discarded.

Pass the cached index directly into SetBlendshape() to eliminate
the redundant per-frame string lookups.

Closes #9

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lavarius merged commit 4e6124644f into master 2026-03-29 15:14:54 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lavarius/ProjectOverlay!40
No description provided.