• R/O
  • SSH
  • HTTPS

mmdx: Commit


Commit MetaInfo

Revision18 (tree)
Zeit2010-03-03 00:53:15
Autorwilfrem

Log Message

アニメーション中にヒープオブジェクト確保していたバグの修正

Ändern Zusammenfassung

Diff

--- trunk/MikuMikuDanceXNA/Model/AnimationPlayer.cs (revision 17)
+++ trunk/MikuMikuDanceXNA/Model/AnimationPlayer.cs (revision 18)
@@ -40,9 +40,9 @@
4040 if (frame > motion.MaxFrame && !IsLoopPlay)
4141 {
4242 Stop();
43- return motion.MaxFrame;
43+ return (decimal)motion.MaxFrame;
4444 }
45- return frame % motion.MaxFrame;
45+ return frame % (decimal)motion.MaxFrame;
4646 }
4747 }
4848 /// <summary>
@@ -179,7 +179,7 @@
179179 /// アニメーションの更新
180180 /// </summary>
181181 /// <remarks>モデルのUpdateから呼ばれるので、ユーザーが呼ぶ必要はありません</remarks>
182- internal void Update(GameTime gameTime)
182+ internal void Update()
183183 {
184184 for (int i=0;i<mmdMotion.Count;i++)
185185 {
@@ -199,7 +199,7 @@
199199 {
200200 #if TRACE
201201 if (mmdModel.mmdXNA.TimeRular != null && mmdModel.UseTimeRular)
202- mmdModel.mmdXNA.TimeRular.BeginMark(2, "Anime-MotionToBone-" + mmdModel.Name, Color.BlueViolet);
202+ mmdModel.mmdXNA.TimeRular.BeginMark(2, "Anime-MotionToBone", Color.BlueViolet);
203203 #endif
204204 //モーションのボーンリストを取得
205205 List<string> motionBones = motion.GetBoneList();
@@ -216,8 +216,8 @@
216216 #if TRACE
217217 if (mmdModel.mmdXNA.TimeRular != null && mmdModel.UseTimeRular)
218218 {
219- mmdModel.mmdXNA.TimeRular.EndMark(2, "Anime-MotionToBone-" + mmdModel.Name);
220- mmdModel.mmdXNA.TimeRular.BeginMark(2, "Anime-IKBone-" + mmdModel.Name, Color.Red);
219+ mmdModel.mmdXNA.TimeRular.EndMark(2, "Anime-MotionToBone");
220+ mmdModel.mmdXNA.TimeRular.BeginMark(2, "Anime-IKBone", Color.Red);
221221 }
222222 #endif
223223 mmdModel.BoneManager.UpdateWorldTransforms();
@@ -230,20 +230,20 @@
230230 #if TRACE
231231 if (mmdModel.mmdXNA.TimeRular != null && mmdModel.UseTimeRular)
232232 {
233- mmdModel.mmdXNA.TimeRular.EndMark(2, "Anime-IKBone-" + mmdModel.Name);
234- mmdModel.mmdXNA.TimeRular.BeginMark(2, "Anime-Face-" + mmdModel.Name, Color.BlueViolet);
233+ mmdModel.mmdXNA.TimeRular.EndMark(2, "Anime-IKBone");
234+ mmdModel.mmdXNA.TimeRular.BeginMark(2, "Anime-Face", Color.BlueViolet);
235235 }
236236 #endif
237237 //フェイスモーションの処理
238238 List<string> faces = motion.GetFaceList();
239239 //リストにあるフェイスのデータを順番に処理
240- foreach(var face in faces)
240+ foreach (var face in faces)
241241 {
242242 mmdModel.FaceManager.SetFace(face, motion.GetFaceRate(face, NowFrame));
243243 }
244244 #if TRACE
245245 if (mmdModel.mmdXNA.TimeRular != null && mmdModel.UseTimeRular)
246- mmdModel.mmdXNA.TimeRular.EndMark(2, "Anime-Face-" + mmdModel.Name);
246+ mmdModel.mmdXNA.TimeRular.EndMark(2, "Anime-Face");
247247 #endif
248248 }
249249 }
--- trunk/MikuMikuDanceXNA/Model/MMDModel.cs (revision 17)
+++ trunk/MikuMikuDanceXNA/Model/MMDModel.cs (revision 18)
@@ -107,11 +107,20 @@
107107 /// <remarks>DrawableGameContentを継承してるため自動更新</remarks>
108108 public override void Update(GameTime gameTime)
109109 {
110+ Update();
111+ base.Update(gameTime);
112+ }
113+ /// <summary>
114+ /// モデルを更新
115+ /// </summary>
116+ /// <remarks>手動更新用</remarks>
117+ public void Update()
118+ {
110119 #if TRACE//速度検査用コード。
111120 if (mmdXNA.TimeRular != null && UseTimeRular)
112121 mmdXNA.TimeRular.BeginMark(1,"Player", Color.BlueViolet);
113122 #endif
114- Player.Update(gameTime);
123+ Player.Update();
115124 #if TRACE
116125 if (mmdXNA.TimeRular != null && UseTimeRular)
117126 {
@@ -126,15 +135,23 @@
126135 #endif
127136 /*if (mmdXNA.UsePhysic)
128137 physics.Update();*/
129- base.Update(gameTime);
130138 }
131139
132140 /// <summary>
133141 /// モデルの描画
134142 /// </summary>
143+ /// <remarks>DrawableGameContentを継承してるため自動更新</remarks>
135144 public override void Draw(GameTime gameTime)
136145 {
137-
146+ Draw();
147+ base.Draw(gameTime);
148+ }
149+ /// <summary>
150+ /// モデルの描画
151+ /// </summary>
152+ /// <remarks>手動更新用</remarks>
153+ public void Draw()
154+ {
138155 //エッジの描画
139156 //描画の退避がうまくできないので、実装中断
140157 #if false
@@ -164,7 +181,6 @@
164181 #endif
165182 ModelDraw(Game.GraphicsDevice, "MMDBasicEffect");//モデルの描画
166183
167- base.Draw(gameTime);
168184 }
169185
170186 private StringBuilder Direction = new StringBuilder("DirLightDirection");
--- trunk/MikuMikuDanceXNA/Motion/MMDMotion.cs (revision 17)
+++ trunk/MikuMikuDanceXNA/Motion/MMDMotion.cs (revision 18)
@@ -188,19 +188,19 @@
188188 {
189189
190190 float Progress = ((float)(NowFrame - motions[BeforePos].FrameNo)) / ((float)(motions[NextPos].FrameNo - motions[BeforePos].FrameNo));
191- float[] ProgXYZ = new float[3];
192- for (int i = 0; i < 3; i++)
193- ProgXYZ[i] = motions[NextPos].Curve[0].Evaluate(Progress);
191+ float ProgX, ProgY, ProgZ;
192+ ProgX = motions[NextPos].Curve[0].Evaluate(Progress);
193+ ProgY = motions[NextPos].Curve[1].Evaluate(Progress);
194+ ProgZ = motions[NextPos].Curve[2].Evaluate(Progress);
195+
194196 float ProgR = motions[NextPos].Curve[0].Evaluate(Progress);
195197 float x,y,z;
196- x = MathHelper.Lerp(motions[BeforePos].Location.X, motions[NextPos].Location.X, ProgXYZ[0]);
197- y = MathHelper.Lerp(motions[BeforePos].Location.Y, motions[NextPos].Location.Y, ProgXYZ[1]);
198- z = MathHelper.Lerp(motions[BeforePos].Location.Z, motions[NextPos].Location.Z, ProgXYZ[2]);
198+ x = MathHelper.Lerp(motions[BeforePos].Location.X, motions[NextPos].Location.X, ProgX);
199+ y = MathHelper.Lerp(motions[BeforePos].Location.Y, motions[NextPos].Location.Y, ProgY);
200+ z = MathHelper.Lerp(motions[BeforePos].Location.Z, motions[NextPos].Location.Z, ProgZ);
199201
200202 v = new Vector3(x, y, z);
201203 q = Quaternion.Slerp(motions[BeforePos].Quatanion, motions[NextPos].Quatanion, ProgR);
202- //q = Quaternion.Slerp(motions[BeforePos].Quatanion, motions[NextPos].Quatanion, Progress);
203- //v = Vector3.Lerp(motions[BeforePos].Location, motions[NextPos].Location, Progress);
204204 }
205205 #if TRACE
206206 if (mmdXNA.TimeRular != null)
Show on old repository browser