OSDN Git Service

refactor.
authornomeu <nomeu@nomeu.org>
Sun, 25 Jan 2015 14:53:29 +0000 (23:53 +0900)
committernomeu <nomeu@nomeu.org>
Sun, 25 Jan 2015 14:53:29 +0000 (23:53 +0900)
TSOGeneratorOneBone.cs
TSOGeneratorRefBone.cs

index 854998e..b5348fa 100644 (file)
@@ -7,8 +7,6 @@ namespace Tso2MqoGui
 {
     public class TSOGeneratorOneBone : TSOGenerator
     {
-        public Dictionary<string, string> ObjectBoneNames = new Dictionary<string, string>();
-
         public TSOGeneratorOneBone(TSOGeneratorConfig config)
             : base(config)
         {
@@ -115,6 +113,8 @@ namespace Tso2MqoGui
             return true;
         }
 
+        public Dictionary<string, string> ObjectBoneNames = new Dictionary<string, string>();
+
         // objに対応するボーンid配列を生成する。
         int[] CreateBones(MqoObject obj)
         {
index ba10167..ed512bc 100644 (file)
@@ -7,26 +7,31 @@ namespace Tso2MqoGui
 {
     public unsafe class TSOGeneratorRefBone : TSOGenerator
     {
-        private List<Vertex> vlst;
-        private PointCluster pc;
-
         public TSOGeneratorRefBone(TSOGeneratorConfig config)
             : base(config)
         {
         }
 
-        private void CreatePointCluster(TSOFile tso)
+        // 参照tso上の全頂点を保持する
+        List<Vertex> refverts;
+        // 最近傍探索
+        PointCluster pc;
+
+        void CreateRefVerts(TSOFile tso)
         {
-            vlst = new List<Vertex>();
+            refverts = new List<Vertex>();
 
             foreach (TSOMesh i in tso.meshes)
                 foreach (TSOSubMesh j in i.sub_meshes)
-                    vlst.AddRange(j.vertices);
+                    refverts.AddRange(j.vertices);
+        }
 
-            pc = new PointCluster(vlst.Count);
+        void CreatePointCluster()
+        {
+            pc = new PointCluster(refverts.Count);
 
-            foreach (Vertex i in vlst)
-                pc.Add(i.Pos.x, i.Pos.y, i.Pos.z);
+            foreach (Vertex i in refverts)
+                pc.Add(i.Pos);
 
             pc.Clustering();
         }
@@ -35,7 +40,8 @@ namespace Tso2MqoGui
         {
             tsoref = LoadTSO(path);
             tsoref.SwitchBoneIndicesOnMesh();
-            CreatePointCluster(tsoref);
+            CreateRefVerts(tsoref);
+            CreatePointCluster();
             return true;
         }
 
@@ -95,9 +101,9 @@ namespace Tso2MqoGui
                             continue;
                         }
 
-                        v[0] = vlst[vref[f.a]];
-                        v[1] = vlst[vref[f.b]];
-                        v[2] = vlst[vref[f.c]];
+                        v[0] = refverts[vref[f.a]];
+                        v[1] = refverts[vref[f.b]];
+                        v[2] = refverts[vref[f.c]];
 
                         work.Clear();
 
@@ -200,7 +206,7 @@ namespace Tso2MqoGui
         protected override bool DoCleanup()
         {
             pc = null;
-            vlst = null;
+            refverts = null;
             return base.DoCleanup();
         }
     }