表情の頂点移動出力計算をDrawからUpdateに移動
@@ -177,6 +177,7 @@ | ||
177 | 177 | } |
178 | 178 | #endif |
179 | 179 | BoneManager.Update(); |
180 | + FaceManager.Update(); | |
180 | 181 | #if TRACE |
181 | 182 | if (mmdXNA.TimeRular != null && UseTimeRular) |
182 | 183 | mmdXNA.TimeRular.EndMark(1, "BoneManager"); |
@@ -246,14 +247,13 @@ | ||
246 | 247 | translationTexture.Flip(); |
247 | 248 | faceTexture.Flip(); |
248 | 249 | |
249 | - //TODO: GetSkinRotation、GetSkinTranslationがボトルネック。原因はO(200)程度の処理量…… | |
250 | 250 | //スキンアニメーション用テクスチャ |
251 | 251 | rotationTexture.Texture.SetData<Quaternion>(BoneManager.GetSkinRotation()); |
252 | 252 | translationTexture.Texture.SetData<Vector4>(BoneManager.GetSkinTranslation()); |
253 | 253 | //フェイステクスチャ |
254 | + //TODO: GetFaceTranslationがボトルネック。 | |
254 | 255 | faceTexture.Texture.SetData<Vector4>(FaceManager.GetFaceTranslation()); |
255 | 256 | |
256 | - | |
257 | 257 | //ライティング設定の取得 |
258 | 258 | Vector3 LightVector, LightColor; |
259 | 259 | mmdXNA.LightManager.GetParameters(out LightVector, out LightColor); |
@@ -1,5 +1,6 @@ | ||
1 | 1 | using System.Collections.Generic; |
2 | 2 | using Microsoft.Xna.Framework; |
3 | +using System; | |
3 | 4 | |
4 | 5 | namespace MikuMikuDance.XNA.Model |
5 | 6 | { |
@@ -41,18 +42,9 @@ | ||
41 | 42 | public void ResetFace() |
42 | 43 | { |
43 | 44 | FaceRates.Clear(); |
44 | - ResetTranslations(); | |
45 | + Array.Clear(FaceTranslations, 0, FaceTranslations.Length); | |
45 | 46 | } |
46 | - private void ResetTranslations() | |
47 | - { | |
48 | - for (int i = 0; i < FaceTranslations.Length; i++) | |
49 | - { | |
50 | - FaceTranslations[i].X = 0; | |
51 | - FaceTranslations[i].Y = 0; | |
52 | - FaceTranslations[i].Z = 0; | |
53 | - FaceTranslations[i].W = 0; | |
54 | - } | |
55 | - } | |
47 | + | |
56 | 48 | /// <summary> |
57 | 49 | /// 表情のセット |
58 | 50 | /// </summary> |
@@ -69,23 +61,23 @@ | ||
69 | 61 | else |
70 | 62 | FaceRates.Add(facename, rate); |
71 | 63 | } |
72 | - | |
73 | - internal Vector4[] GetFaceTranslation() | |
64 | + internal void Update() | |
74 | 65 | { |
75 | - ResetTranslations();//まずは表情をリセットしておく | |
66 | + Array.Clear(FaceTranslations, 0, FaceTranslations.Length); | |
67 | + //ResetTranslations();//まずは表情をリセットしておく | |
76 | 68 | //次に表情名に合わせて頂点とその移動量を合算する |
77 | 69 | foreach (var face in FaceRates) |
78 | 70 | {//各表情ごとに頂点移動量の合成処理 |
79 | 71 | if (!FaceDictionary.ContainsKey(face.Key)) |
80 | 72 | continue;//対象表情が無いのでパス |
81 | - float temp; | |
82 | - if (face.Key == "あ") | |
83 | - temp=face.Value; | |
84 | 73 | foreach (var vert in model.ModelData.Skins[FaceDictionary[face.Key]].SkinVerts) |
85 | 74 | { |
86 | 75 | FaceTranslations[vert.VertIndex] += (new Vector4(vert.Pos[0], vert.Pos[1], vert.Pos[2], 0) * face.Value); |
87 | 76 | } |
88 | 77 | } |
78 | + } | |
79 | + internal Vector4[] GetFaceTranslation() | |
80 | + { | |
89 | 81 | return FaceTranslations; |
90 | 82 | } |
91 | 83 | } |