[PERF] FaceTrackerClient: GetBlendShapeIndex() string lookup called every frame #9

Closed
opened 2026-03-12 00:02:46 +00:00 by lavarius · 0 comments
Owner

🟠 High — Performance

File: FaceTrackerClient.cs

sharedMesh.GetBlendShapeIndex(name) performs a string lookup every frame per blendshape. This is expensive and unnecessary since blend shape indices don't change at runtime.

Fix: In Start(), build a cache:

private Dictionary<string, int> blendShapeIndexCache;

void Start()
{
    blendShapeIndexCache = new Dictionary<string, int>();
    for (int i = 0; i < sharedMesh.blendShapeCount; i++)
        blendShapeIndexCache[sharedMesh.GetBlendShapeName(i)] = i;
}
## 🟠 High — Performance **File:** `FaceTrackerClient.cs` `sharedMesh.GetBlendShapeIndex(name)` performs a string lookup every frame per blendshape. This is expensive and unnecessary since blend shape indices don't change at runtime. **Fix:** In `Start()`, build a cache: ```csharp private Dictionary<string, int> blendShapeIndexCache; void Start() { blendShapeIndexCache = new Dictionary<string, int>(); for (int i = 0; i < sharedMesh.blendShapeCount; i++) blendShapeIndexCache[sharedMesh.GetBlendShapeName(i)] = i; } ```
Sign in to join this conversation.
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#9
No description provided.