DynamicSkirtBone.cs 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Runtime.InteropServices;
  5. using UnityEngine;
  6. public class DynamicSkirtBone : MonoBehaviour
  7. {
  8. [DllImport("kernel32.dll")]
  9. private static extern IntPtr LoadLibraryW(byte[] dllToLoad);
  10. [DllImport("kernel32.dll")]
  11. private static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
  12. [DllImport("kernel32.dll")]
  13. private static extern bool FreeLibrary(IntPtr hModule);
  14. public bool SerializeWrite(BinaryWriter f_bw)
  15. {
  16. f_bw.Write("CM3D21_PSK");
  17. f_bw.Write(1320);
  18. f_bw.Write(this.m_fPanierRadius);
  19. this.SerializeWriteAnimationCurve(f_bw, this.m_PanierRadiusDistrib);
  20. int num = (this.m_PanierRadiusDistribGroup == null) ? 0 : this.m_PanierRadiusDistribGroup.Length;
  21. f_bw.Write(num);
  22. for (int i = 0; i < num; i++)
  23. {
  24. DynamicSkirtBone.PanierRadiusGroup panierRadiusGroup = this.m_PanierRadiusDistribGroup[i];
  25. f_bw.Write(panierRadiusGroup.strBoneName);
  26. f_bw.Write(panierRadiusGroup.fRadius);
  27. this.SerializeWriteAnimationCurve(f_bw, panierRadiusGroup.Curve);
  28. }
  29. f_bw.Write(this.m_fPanierForce);
  30. this.SerializeWriteAnimationCurve(f_bw, this.m_PanierForceDistrib);
  31. f_bw.Write(this.m_fPanierStressForce);
  32. f_bw.Write(this.m_fStressDgreeMin);
  33. f_bw.Write(this.m_fStressDgreeMax);
  34. f_bw.Write(this.m_fStressMinScale);
  35. f_bw.Write(this.m_fScaleEaseSpeed);
  36. f_bw.Write(this.m_fPanierForceDistanceThreshold);
  37. f_bw.Write(this.m_nCalcTime);
  38. f_bw.Write(this.m_fVelocityForceRate);
  39. this.SerializeWriteAnimationCurve(f_bw, this.m_VelocityForceRateDistrib);
  40. f_bw.Write(this.m_vGravity.x);
  41. f_bw.Write(this.m_vGravity.y);
  42. f_bw.Write(this.m_vGravity.z);
  43. this.SerializeWriteAnimationCurve(f_bw, this.m_GravityDistrib);
  44. f_bw.Write(this.m_aryHard[0]);
  45. f_bw.Write(this.m_aryHard[1]);
  46. f_bw.Write(this.m_aryHard[2]);
  47. f_bw.Write(this.m_aryHard[3]);
  48. return true;
  49. }
  50. private void SerializeWriteAnimationCurve(BinaryWriter f_bw, AnimationCurve f_ac)
  51. {
  52. Keyframe[] keys = f_ac.keys;
  53. f_bw.Write(keys.Length);
  54. for (int i = 0; i < keys.Length; i++)
  55. {
  56. f_bw.Write(keys[i].time);
  57. f_bw.Write(keys[i].value);
  58. f_bw.Write(keys[i].inTangent);
  59. f_bw.Write(keys[i].outTangent);
  60. }
  61. }
  62. public void SerializeRead(BinaryReader f_br)
  63. {
  64. string a = f_br.ReadString();
  65. if (a != "CM3D21_PSK")
  66. {
  67. NDebug.Assert("物理スカート定義ヘッダー不正", false);
  68. }
  69. int num = f_br.ReadInt32();
  70. this.m_fPanierRadius = f_br.ReadSingle();
  71. this.SerializeReadAnimationCurve(f_br, out this.m_PanierRadiusDistrib);
  72. if (217 <= num)
  73. {
  74. int num2 = f_br.ReadInt32();
  75. if (num2 != 0)
  76. {
  77. this.m_PanierRadiusDistribGroup = new DynamicSkirtBone.PanierRadiusGroup[num2];
  78. }
  79. for (int i = 0; i < num2; i++)
  80. {
  81. DynamicSkirtBone.PanierRadiusGroup panierRadiusGroup = new DynamicSkirtBone.PanierRadiusGroup();
  82. panierRadiusGroup.strBoneName = f_br.ReadString();
  83. panierRadiusGroup.fRadius = f_br.ReadSingle();
  84. this.SerializeReadAnimationCurve(f_br, out panierRadiusGroup.Curve);
  85. this.m_PanierRadiusDistribGroup[i] = panierRadiusGroup;
  86. }
  87. }
  88. this.m_fPanierForce = f_br.ReadSingle();
  89. this.SerializeReadAnimationCurve(f_br, out this.m_PanierForceDistrib);
  90. this.m_fPanierStressForce = f_br.ReadSingle();
  91. this.m_fStressDgreeMin = f_br.ReadSingle();
  92. this.m_fStressDgreeMax = f_br.ReadSingle();
  93. this.m_fStressMinScale = f_br.ReadSingle();
  94. this.m_fScaleEaseSpeed = f_br.ReadSingle();
  95. this.m_fPanierForceDistanceThreshold = f_br.ReadSingle();
  96. this.m_nCalcTime = f_br.ReadInt32();
  97. this.m_fVelocityForceRate = f_br.ReadSingle();
  98. this.SerializeReadAnimationCurve(f_br, out this.m_VelocityForceRateDistrib);
  99. this.m_vGravity.x = f_br.ReadSingle();
  100. this.m_vGravity.y = f_br.ReadSingle();
  101. this.m_vGravity.z = f_br.ReadSingle();
  102. this.SerializeReadAnimationCurve(f_br, out this.m_GravityDistrib);
  103. this.m_aryHard[0] = f_br.ReadSingle();
  104. this.m_aryHard[1] = f_br.ReadSingle();
  105. this.m_aryHard[2] = f_br.ReadSingle();
  106. this.m_aryHard[3] = f_br.ReadSingle();
  107. this.UpdateParameters();
  108. }
  109. private void SerializeReadAnimationCurve(BinaryReader f_br, out AnimationCurve f_ac)
  110. {
  111. int num = f_br.ReadInt32();
  112. f_ac = null;
  113. if (num != 0)
  114. {
  115. Keyframe[] array = new Keyframe[num];
  116. for (int i = 0; i < num; i++)
  117. {
  118. array[i] = new Keyframe
  119. {
  120. time = f_br.ReadSingle(),
  121. value = f_br.ReadSingle(),
  122. inTangent = f_br.ReadSingle(),
  123. outTangent = f_br.ReadSingle()
  124. };
  125. }
  126. f_ac = new AnimationCurve(array);
  127. }
  128. }
  129. public bool InitGameObject(GameObject f_objRoot, TBodySkin bodyskin, Transform f_trSkirtRoot)
  130. {
  131. this.m_BodySkin = bodyskin;
  132. this.m_Body = bodyskin.body;
  133. if (DynamicSkirtBone.m_PluginDll == IntPtr.Zero)
  134. {
  135. string text = Application.dataPath + '/' + "Plugins/clothpp.dll";
  136. Debug.Log("Application.dataPath is " + text);
  137. DynamicSkirtBone.m_PluginDll = DynamicSkirtBone.LoadLibraryW(NUty.ConvStringToByte(text, NUty.ENCO.UTF_16));
  138. IntPtr procAddress = DynamicSkirtBone.GetProcAddress(DynamicSkirtBone.m_PluginDll, "Export_PhysicsCreate");
  139. DynamicSkirtBone.m_dgExport_PhysicsCreate = (DynamicSkirtBone.Export_PhysicsCreate)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(DynamicSkirtBone.Export_PhysicsCreate));
  140. IntPtr procAddress2 = DynamicSkirtBone.GetProcAddress(DynamicSkirtBone.m_PluginDll, "Export_PhysicsDelete");
  141. DynamicSkirtBone.m_dgExport_PhysicsDelete = (DynamicSkirtBone.Export_PhysicsDelete)Marshal.GetDelegateForFunctionPointer(procAddress2, typeof(DynamicSkirtBone.Export_PhysicsDelete));
  142. IntPtr procAddress3 = DynamicSkirtBone.GetProcAddress(DynamicSkirtBone.m_PluginDll, "Export_InitSkirt");
  143. DynamicSkirtBone.m_dgExport_InitSkirt = (DynamicSkirtBone.Export_InitSkirt)Marshal.GetDelegateForFunctionPointer(procAddress3, typeof(DynamicSkirtBone.Export_InitSkirt));
  144. IntPtr procAddress4 = DynamicSkirtBone.GetProcAddress(DynamicSkirtBone.m_PluginDll, "Export_GetBonePos");
  145. DynamicSkirtBone.m_dgExport_GetBonePos = (DynamicSkirtBone.Export_GetBonePos)Marshal.GetDelegateForFunctionPointer(procAddress4, typeof(DynamicSkirtBone.Export_GetBonePos));
  146. }
  147. NDebug.Assert(this.m_nDllPhysicsInstanceID == -1, () => "Skirt DLL多重ロード。");
  148. this.m_nDllPhysicsInstanceID = DynamicSkirtBone.m_dgExport_PhysicsCreate();
  149. this.m_nBoneCount = 0;
  150. this.m_listBoneScaleDef.Clear();
  151. this.m_listHookBoneTrs = new List<Transform>();
  152. int num = -1;
  153. int num2 = f_trSkirtRoot.childCount - 1;
  154. while (0 <= num2)
  155. {
  156. Transform child = f_trSkirtRoot.GetChild(num2);
  157. if (child.name.Contains("Skirt") && child.name.Contains("_A_"))
  158. {
  159. int num3 = int.Parse(child.name.Substring(5, 2)) - 1;
  160. if (num == -1)
  161. {
  162. num = num3;
  163. }
  164. num3 = num - num3;
  165. Vector3 position = child.position;
  166. this.m_aryBonePos[num3 * 3] = position.x;
  167. this.m_aryBonePos[num3 * 3 + 1] = position.y;
  168. this.m_aryBonePos[num3 * 3 + 2] = position.z;
  169. this.m_aryBoneTrs[num3] = child;
  170. this.m_listHookBoneTrs.Add(child);
  171. }
  172. num2--;
  173. }
  174. this.m_nHookBoneCount = this.m_listHookBoneTrs.Count;
  175. this.m_nBoneCount = this.m_nHookBoneCount;
  176. this.m_bOldBone = (this.m_nHookBoneCount <= 12);
  177. float num4 = 0f;
  178. for (int i = 0; i < this.m_nHookBoneCount; i++)
  179. {
  180. int num5 = 0;
  181. Transform transform = this.m_listHookBoneTrs[i];
  182. if (transform.localScale.x < 0.999f || 1.001f < transform.localScale.x || transform.localScale.y < 0.999f || 1.001f < transform.localScale.y || transform.localScale.z < 0.999f || 1.001f < transform.localScale.z)
  183. {
  184. this.m_listBoneScaleDef.Add(new BoneScaleDef(transform, transform.localPosition, transform.localRotation, transform.localScale));
  185. }
  186. this.m_aryBoneLength[i] = 0f;
  187. float num6 = 0f;
  188. while (transform.childCount > 0)
  189. {
  190. Vector3 position2 = transform.position;
  191. transform = transform.GetChild(0);
  192. if (transform.localScale.x < 0.999f || 1.001f < transform.localScale.x || transform.localScale.y < 0.999f || 1.001f < transform.localScale.y || transform.localScale.z < 0.999f || 1.001f < transform.localScale.z)
  193. {
  194. this.m_listBoneScaleDef.Add(new BoneScaleDef(transform, transform.localPosition, transform.localRotation, transform.localScale));
  195. }
  196. num6 += (position2 - transform.position).magnitude;
  197. Vector3 position3 = transform.position;
  198. this.m_aryBonePos[(num5 + 1) * (this.m_nHookBoneCount * 3) + i * 3] = position3.x;
  199. this.m_aryBonePos[(num5 + 1) * (this.m_nHookBoneCount * 3) + i * 3 + 1] = position3.y;
  200. this.m_aryBonePos[(num5 + 1) * (this.m_nHookBoneCount * 3) + i * 3 + 2] = position3.z;
  201. this.m_aryBoneTrs[(num5 + 1) * this.m_nHookBoneCount + i] = transform;
  202. this.m_aryBoneLength[(num5 + 1) * this.m_nHookBoneCount + i] = num6;
  203. this.m_nBoneCount++;
  204. num5++;
  205. }
  206. if (num4 < num6)
  207. {
  208. num4 = num6;
  209. }
  210. }
  211. this.m_fMaxLenght = num4;
  212. for (int j = 0; j < this.m_nBoneCount; j++)
  213. {
  214. this.m_aryBoneLengthRate[j] = this.m_aryBoneLength[j] / this.m_fMaxLenght;
  215. }
  216. this.m_aryVelocityForceRate = new float[this.m_nBoneCount];
  217. this.m_aryGravity = new float[this.m_nBoneCount * 3];
  218. this.m_trPanierParent = new GameObject("Skirt_P").transform;
  219. this.m_trPanierParent.SetParent(f_trSkirtRoot, false);
  220. this.m_trPanierParent.position = f_trSkirtRoot.position;
  221. this.m_trPanierParent.rotation = f_trSkirtRoot.rotation;
  222. this.m_aryPanierBoneTrs = new Transform[this.m_nBoneCount];
  223. this.m_aryPanierForce = new float[this.m_nBoneCount];
  224. this.m_aryPanierRadius = new float[this.m_nBoneCount];
  225. this.m_aryPanierBoneToLegSegRate = new float[this.m_nBoneCount];
  226. this.m_aryPanierBoneBeforeRotAngle = new float[this.m_nBoneCount];
  227. this.m_fPanierStress = new float[this.m_nHookBoneCount];
  228. this.m_fPanierVecAngle = new float[this.m_nHookBoneCount];
  229. this.m_aryPanierLastChildDef = new Transform[this.m_nHookBoneCount];
  230. Dictionary<string, ImportCM.OldSkirtBoneRev> dictionary = null;
  231. if (this.m_bOldBone)
  232. {
  233. dictionary = ImportCM.LoadOldSkirtBoneRev(f_objRoot.name);
  234. this.m_bPanierOldBoneRotRev = new bool[this.m_nBoneCount];
  235. this.m_vPanierOldBoneRotRevInit = new Vector3[this.m_nBoneCount];
  236. this.m_vPanierOldBoneRotRevAfter = new Vector3[this.m_nBoneCount];
  237. }
  238. int num7 = 0;
  239. for (int k = 0; k < this.m_nHookBoneCount; k++)
  240. {
  241. GameObject gameObject = new GameObject("Skirt_P_" + k + "_0");
  242. gameObject.transform.SetParent(this.m_trPanierParent, false);
  243. Transform transform2 = this.m_listHookBoneTrs[k];
  244. gameObject.transform.position = transform2.position;
  245. gameObject.transform.rotation = transform2.rotation;
  246. bool flag = false;
  247. Vector3 vector = Vector3.zero;
  248. Vector3 vector2 = Vector3.zero;
  249. if (this.m_bOldBone)
  250. {
  251. ImportCM.OldSkirtBoneRev oldSkirtBoneRev;
  252. if (dictionary != null && dictionary.TryGetValue(transform2.name, out oldSkirtBoneRev))
  253. {
  254. this.m_bPanierOldBoneRotRev[k] = true;
  255. this.m_vPanierOldBoneRotRevInit[k] = oldSkirtBoneRev.vRotRevInit;
  256. this.m_vPanierOldBoneRotRevAfter[k] = oldSkirtBoneRev.vRotRevAfter;
  257. flag = oldSkirtBoneRev.bRecursiv;
  258. if (flag)
  259. {
  260. vector = oldSkirtBoneRev.vRotRevInit;
  261. vector2 = oldSkirtBoneRev.vRotRevAfter;
  262. }
  263. }
  264. else
  265. {
  266. Vector3 normalized = (this.m_listHookBoneTrs[(k + 1 >= this.m_nHookBoneCount) ? 0 : (k + 1)].position - this.m_listHookBoneTrs[k].position).normalized;
  267. float num8 = Vector3.Dot(normalized, -this.m_listHookBoneTrs[k].forward);
  268. if (num8 < 0.1f)
  269. {
  270. this.m_bPanierOldBoneRotRev[k] = true;
  271. flag = true;
  272. float num9 = Vector3.Dot(normalized, this.m_listHookBoneTrs[k].forward);
  273. if (-0.1 < (double)num9 && num9 < 0.5f)
  274. {
  275. Vector3[] vPanierOldBoneRotRevInit = this.m_vPanierOldBoneRotRevInit;
  276. int num10 = k;
  277. vector = new Vector3(90f, 0f, 0f);
  278. vPanierOldBoneRotRevInit[num10] = vector;
  279. Vector3[] vPanierOldBoneRotRevAfter = this.m_vPanierOldBoneRotRevAfter;
  280. int num11 = k;
  281. vector2 = new Vector3(-90f, 0f, 0f);
  282. vPanierOldBoneRotRevAfter[num11] = vector2;
  283. }
  284. else
  285. {
  286. Vector3[] vPanierOldBoneRotRevInit2 = this.m_vPanierOldBoneRotRevInit;
  287. int num12 = k;
  288. vector = new Vector3(180f, 0f, 0f);
  289. vPanierOldBoneRotRevInit2[num12] = vector;
  290. Vector3[] vPanierOldBoneRotRevAfter2 = this.m_vPanierOldBoneRotRevAfter;
  291. int num13 = k;
  292. vector2 = new Vector3(-180f, 0f, 0f);
  293. vPanierOldBoneRotRevAfter2[num13] = vector2;
  294. }
  295. }
  296. }
  297. if (this.m_bPanierOldBoneRotRev[k])
  298. {
  299. gameObject.transform.Rotate(this.m_vPanierOldBoneRotRevInit[k], Space.Self);
  300. }
  301. }
  302. this.m_aryPanierBoneTrs[k] = gameObject.transform;
  303. int num14 = 0;
  304. int num15 = 0;
  305. Transform transform3 = this.m_listHookBoneTrs[k];
  306. while (transform3.childCount > 0)
  307. {
  308. transform3 = transform3.GetChild(0);
  309. int num16 = num15 * this.m_nHookBoneCount + k;
  310. int num17 = (num15 + 1) * this.m_nHookBoneCount + k;
  311. GameObject gameObject2 = new GameObject(string.Concat(new object[]
  312. {
  313. "Skirt_P_",
  314. k,
  315. "_",
  316. 1 + num15
  317. }));
  318. gameObject2.transform.SetParent(this.m_aryPanierBoneTrs[num16], false);
  319. gameObject2.transform.position = transform3.position;
  320. gameObject2.transform.rotation = transform3.rotation;
  321. if (this.m_bOldBone)
  322. {
  323. ImportCM.OldSkirtBoneRev oldSkirtBoneRev2;
  324. if (flag)
  325. {
  326. this.m_bPanierOldBoneRotRev[num17] = true;
  327. this.m_vPanierOldBoneRotRevInit[num17] = vector;
  328. this.m_vPanierOldBoneRotRevAfter[num17] = vector2;
  329. }
  330. else if (!flag && dictionary != null && dictionary.TryGetValue(transform2.name, out oldSkirtBoneRev2))
  331. {
  332. this.m_bPanierOldBoneRotRev[num17] = true;
  333. this.m_vPanierOldBoneRotRevInit[num17] = oldSkirtBoneRev2.vRotRevInit;
  334. this.m_vPanierOldBoneRotRevAfter[num17] = oldSkirtBoneRev2.vRotRevAfter;
  335. flag = oldSkirtBoneRev2.bRecursiv;
  336. if (flag)
  337. {
  338. vector = oldSkirtBoneRev2.vRotRevInit;
  339. vector2 = oldSkirtBoneRev2.vRotRevAfter;
  340. }
  341. }
  342. if (this.m_bPanierOldBoneRotRev[num17])
  343. {
  344. gameObject2.transform.Rotate(this.m_vPanierOldBoneRotRevInit[num17], Space.Self);
  345. }
  346. }
  347. this.m_aryPanierBoneTrs[num17] = gameObject2.transform;
  348. num15++;
  349. num14++;
  350. }
  351. if (num7 < num14)
  352. {
  353. num7 = num14;
  354. }
  355. }
  356. this.m_aryPanierBoneDefRot = new Quaternion[this.m_nBoneCount];
  357. for (int l = 0; l < this.m_nHookBoneCount; l++)
  358. {
  359. Transform transform4 = this.m_aryPanierBoneTrs[l];
  360. this.m_aryPanierBoneDefRot[l] = transform4.localRotation;
  361. int num18 = 0;
  362. while (transform4.childCount > 0)
  363. {
  364. transform4 = transform4.GetChild(0);
  365. this.m_aryPanierBoneDefRot[(num18 + 1) * this.m_nHookBoneCount + l] = transform4.localRotation;
  366. num18++;
  367. }
  368. }
  369. this.m_aryLegSeqRadius[0] = 0.1630143f;
  370. this.m_aryLegSeqRadius[1] = 0.2130143f;
  371. this.m_aryLegSeqRadius[2] = 0.5f;
  372. this.m_aryLegSeqRadius[3] = 0.5f;
  373. this.m_aryLegSeqRadius[4] = 0.5f;
  374. this.m_aryLegSeqRadius[5] = 0.5f;
  375. this.m_nPanierBoneCount = this.m_nBoneCount;
  376. for (int m = 0; m < this.m_nBoneCount * 3; m++)
  377. {
  378. this.m_aryPanierBonePos[m] = this.m_aryBonePos[m];
  379. }
  380. this.m_nBodyBallCount = 2;
  381. Transform pelvis = this.m_Body.Pelvis;
  382. int num19 = 0;
  383. GameObject gameObject3 = new GameObject("Hit_HipL");
  384. gameObject3.transform.SetParent(pelvis);
  385. this.m_listBodyBallPos.Add(gameObject3.transform);
  386. DynamicBoneCollider dynamicBoneCollider;
  387. this.m_listBodyBall.Add(dynamicBoneCollider = gameObject3.AddComponent<DynamicBoneCollider>());
  388. dynamicBoneCollider.m_Radius = 0.09f;
  389. gameObject3.transform.localPosition = new Vector3(-0.0181f, -0.0319f, 0.0573f);
  390. gameObject3.transform.localScale = new Vector3(1f, 1f, 1f);
  391. this.m_aryBodyBallPos[3 * num19] = gameObject3.transform.position.x;
  392. this.m_aryBodyBallPos[3 * num19 + 1] = gameObject3.transform.position.y;
  393. this.m_aryBodyBallPos[3 * num19 + 2] = gameObject3.transform.position.z;
  394. this.m_aryBodyBallRadius[num19] = dynamicBoneCollider.GetLossyScale();
  395. num19 = 1;
  396. GameObject gameObject4 = new GameObject("Hit_HipR");
  397. gameObject4.transform.SetParent(pelvis);
  398. this.m_listBodyBallPos.Add(gameObject4.transform);
  399. this.m_listBodyBall.Add(dynamicBoneCollider = gameObject4.AddComponent<DynamicBoneCollider>());
  400. dynamicBoneCollider.m_Radius = 0.09f;
  401. gameObject4.transform.localPosition = new Vector3(-0.0181f, -0.0319f, -0.0573f);
  402. gameObject4.transform.localScale = new Vector3(1f, 1f, 1f);
  403. this.m_aryBodyBallPos[3 * num19] = gameObject4.transform.position.x;
  404. this.m_aryBodyBallPos[3 * num19 + 1] = gameObject4.transform.position.y;
  405. this.m_aryBodyBallPos[3 * num19 + 2] = gameObject4.transform.position.z;
  406. this.m_aryBodyBallRadius[num19] = dynamicBoneCollider.GetLossyScale();
  407. GameObject gameObject5 = new GameObject("Hit_Vag");
  408. gameObject5.transform.SetParent(pelvis);
  409. this.m_listBodyBallPos.Add(gameObject5.transform);
  410. this.m_listBodyBall.Add(dynamicBoneCollider = gameObject5.AddComponent<DynamicBoneCollider>());
  411. dynamicBoneCollider.m_Radius = 0.09f;
  412. gameObject5.transform.localPosition = new Vector3(-0.022f, 0.023f, 0f);
  413. gameObject5.transform.localScale = new Vector3(1f, 1f, 1f);
  414. this.m_nBodyCapsuleCount = 4;
  415. this.m_aryCapsuleBoneTrs = new Transform[this.m_nBodyCapsuleCount * 2];
  416. this.m_aryCapsuleBoneTrs[0] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 L Thigh", true);
  417. this.m_aryCapsuleBoneTrs[1] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 L Calf", true);
  418. this.m_aryCapsuleBoneTrs[2] = this.m_aryCapsuleBoneTrs[1];
  419. this.m_aryCapsuleBoneTrs[3] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 L Foot", true);
  420. this.m_aryCapsuleBoneTrs[4] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 R Thigh", true);
  421. this.m_aryCapsuleBoneTrs[5] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 R Calf", true);
  422. this.m_aryCapsuleBoneTrs[6] = this.m_aryCapsuleBoneTrs[5];
  423. this.m_aryCapsuleBoneTrs[7] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 R Foot", true);
  424. this.m_aryTestCapsule = new Transform[this.m_nBodyCapsuleCount * 2];
  425. for (int n = 0; n < this.m_nBodyCapsuleCount; n++)
  426. {
  427. this.m_aryBodyCapsulePos[6 * n] = this.m_aryCapsuleBoneTrs[2 * n].position.x;
  428. this.m_aryBodyCapsulePos[6 * n + 1] = this.m_aryCapsuleBoneTrs[2 * n].position.y;
  429. this.m_aryBodyCapsulePos[6 * n + 2] = this.m_aryCapsuleBoneTrs[2 * n].position.z;
  430. this.m_aryBodyCapsulePos[6 * n + 3] = this.m_aryCapsuleBoneTrs[2 * n + 1].position.x;
  431. this.m_aryBodyCapsulePos[6 * n + 4] = this.m_aryCapsuleBoneTrs[2 * n + 1].position.y;
  432. this.m_aryBodyCapsulePos[6 * n + 5] = this.m_aryCapsuleBoneTrs[2 * n + 1].position.z;
  433. this.m_aryBodyCapsuleRadius[n] = this.m_fRegDefaultRadius;
  434. }
  435. Vector3 vector3 = this.m_Body.Pelvis.TransformPoint(new Vector3(-1f, 0f, 0f));
  436. this.m_vLegPelvisToSpine[0] = vector3.x;
  437. this.m_vLegPelvisToSpine[1] = vector3.y;
  438. this.m_vLegPelvisToSpine[2] = vector3.z;
  439. Vector3 vector4 = this.m_Body.Pelvis.TransformPoint(new Vector3(0f, 1f, 0f)) - this.m_Body.Pelvis.position;
  440. this.m_vLegPelvisToSpine[3] = vector4.x;
  441. this.m_vLegPelvisToSpine[4] = vector4.y;
  442. this.m_vLegPelvisToSpine[5] = vector4.z;
  443. this.m_aryLegSeqRadius[0] = this.m_fLegSeqRad0;
  444. this.m_aryLegSeqRadius[1] = this.m_fLegSeqRad1;
  445. this.m_aryLegSeqRadius[2] = this.m_fLegSeqRad1;
  446. this.m_aryLegSeqRadius[3] = this.m_fLegSeqRad2;
  447. this.m_aryLegSeqRadius[4] = this.m_fLegSeqRad2;
  448. this.m_aryLegSeqRadius[5] = this.m_fLegSeqRad3;
  449. this.UpdateParameters();
  450. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBonePos, GCHandleType.Pinned));
  451. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryPanierBonePos, GCHandleType.Pinned));
  452. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryHookBonePos, GCHandleType.Pinned));
  453. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBodyBallPos, GCHandleType.Pinned));
  454. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBodyBallRadius, GCHandleType.Pinned));
  455. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBodyCapsulePos, GCHandleType.Pinned));
  456. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBodyCapsuleRadius, GCHandleType.Pinned));
  457. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryDebugLegSeqPos, GCHandleType.Pinned));
  458. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryLegSeqRadius, GCHandleType.Pinned));
  459. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_vLegPelvisToSpine, GCHandleType.Pinned));
  460. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBoneParam, GCHandleType.Pinned));
  461. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryPanierForce, GCHandleType.Pinned));
  462. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryVelocityForceRate, GCHandleType.Pinned));
  463. this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryGravity, GCHandleType.Pinned));
  464. DynamicSkirtBone.m_dgExport_InitSkirt(this.m_nDllPhysicsInstanceID, this.m_aryHard[0], this.m_aryHard[1], this.m_aryHard[2], this.m_aryHard[3], this.m_aryBonePos, this.m_nBoneCount, this.m_nHookBoneCount, this.m_nBodyBallCount, this.m_aryBodyBallPos, this.m_aryBodyBallRadius, this.m_nBodyCapsuleCount, this.m_aryBodyCapsulePos, this.m_aryBodyCapsuleRadius, this.m_vLegPelvisToSpine, this.m_aryLegSeqRadius);
  465. return true;
  466. }
  467. public void OnPreFinalize()
  468. {
  469. if (DynamicSkirtBone.m_PluginDll != IntPtr.Zero)
  470. {
  471. if (this.m_nDllPhysicsInstanceID != -1)
  472. {
  473. DynamicSkirtBone.m_dgExport_PhysicsDelete(this.m_nDllPhysicsInstanceID);
  474. this.m_nDllPhysicsInstanceID = -1;
  475. }
  476. DynamicSkirtBone.FreeLibrary(DynamicSkirtBone.m_PluginDll);
  477. DynamicSkirtBone.m_PluginDll = IntPtr.Zero;
  478. }
  479. DynamicSkirtBone.m_dgExport_PhysicsCreate = null;
  480. DynamicSkirtBone.m_dgExport_PhysicsDelete = null;
  481. DynamicSkirtBone.m_dgExport_InitSkirt = null;
  482. DynamicSkirtBone.m_dgExport_GetBonePos = null;
  483. }
  484. private void OnDestroy()
  485. {
  486. this.Uninit();
  487. }
  488. private void OnValidate()
  489. {
  490. this.UpdateParameters();
  491. }
  492. public void Uninit()
  493. {
  494. if (this.m_nDllPhysicsInstanceID != -1)
  495. {
  496. if (DynamicSkirtBone.m_dgExport_PhysicsDelete != null)
  497. {
  498. DynamicSkirtBone.m_dgExport_PhysicsDelete(this.m_nDllPhysicsInstanceID);
  499. }
  500. this.m_nDllPhysicsInstanceID = -1;
  501. }
  502. foreach (Transform transform in this.m_listBodyBallPos)
  503. {
  504. UnityEngine.Object.Destroy(transform.gameObject);
  505. }
  506. this.m_listBodyBallPos.Clear();
  507. this.m_listBodyBall.Clear();
  508. for (int i = 0; i < this.m_listGcHandle.Count; i++)
  509. {
  510. GCHandle gchandle = this.m_listGcHandle[i];
  511. if (gchandle.IsAllocated)
  512. {
  513. gchandle.Free();
  514. }
  515. }
  516. this.m_listGcHandle.Clear();
  517. if (this.m_aryTestCapsule != null)
  518. {
  519. foreach (Transform transform2 in this.m_aryTestCapsule)
  520. {
  521. if (transform2 != null && transform2.gameObject != null)
  522. {
  523. UnityEngine.Object.DestroyImmediate(transform2.gameObject);
  524. }
  525. }
  526. this.m_aryTestCapsule = null;
  527. }
  528. }
  529. public void UpdateParameters()
  530. {
  531. bool flag = this.m_PanierRadiusDistrib != null && this.m_PanierRadiusDistrib.length != 0;
  532. bool flag2 = this.m_PanierForceDistrib != null && this.m_PanierForceDistrib.length != 0;
  533. bool flag3 = this.m_VelocityForceRateDistrib != null && this.m_VelocityForceRateDistrib.length != 0;
  534. bool flag4 = this.m_GravityDistrib != null && this.m_GravityDistrib.length != 0;
  535. int nH;
  536. for (nH = 0; nH < this.m_nHookBoneCount; nH++)
  537. {
  538. DynamicSkirtBone.PanierRadiusGroup panierRadiusGroup = null;
  539. if (this.m_PanierRadiusDistribGroup != null)
  540. {
  541. panierRadiusGroup = Array.Find<DynamicSkirtBone.PanierRadiusGroup>(this.m_PanierRadiusDistribGroup, (DynamicSkirtBone.PanierRadiusGroup a) => a.strBoneName == this.m_aryBoneTrs[nH].name);
  542. }
  543. int num = this.m_nBoneCount / this.m_nHookBoneCount;
  544. for (int i = 0; i < num; i++)
  545. {
  546. int num2 = i * this.m_nHookBoneCount + nH;
  547. float time = this.m_aryBoneLength[num2];
  548. if (panierRadiusGroup == null)
  549. {
  550. float num3 = this.m_fPanierRadius;
  551. if (flag)
  552. {
  553. num3 *= this.m_PanierRadiusDistrib.Evaluate(time);
  554. }
  555. this.m_aryPanierRadius[num2] = num3;
  556. }
  557. else
  558. {
  559. float num4 = panierRadiusGroup.fRadius;
  560. if (panierRadiusGroup.Curve != null && panierRadiusGroup.Curve.length != 0)
  561. {
  562. num4 *= panierRadiusGroup.Curve.Evaluate(time);
  563. }
  564. this.m_aryPanierRadius[num2] = num4;
  565. }
  566. float num5 = this.m_fPanierForce;
  567. if (flag2)
  568. {
  569. num5 *= this.m_PanierForceDistrib.Evaluate(time);
  570. }
  571. this.m_aryPanierForce[num2] = num5;
  572. float num6 = this.m_fVelocityForceRate;
  573. if (flag3)
  574. {
  575. num6 *= this.m_VelocityForceRateDistrib.Evaluate(time);
  576. }
  577. this.m_aryVelocityForceRate[num2] = num6;
  578. Vector3 a2 = this.m_vGravity;
  579. if (flag4)
  580. {
  581. a2 *= this.m_GravityDistrib.Evaluate(time);
  582. }
  583. this.m_aryGravity[num2 * 3] = a2.x;
  584. this.m_aryGravity[num2 * 3 + 1] = a2.y;
  585. this.m_aryGravity[num2 * 3 + 2] = a2.z;
  586. }
  587. }
  588. }
  589. public void UpdateSelf()
  590. {
  591. if (DynamicSkirtBone.m_dgExport_GetBonePos == null)
  592. {
  593. return;
  594. }
  595. if (this.m_listBoneScaleDef.Count != 0)
  596. {
  597. for (int i = 0; i < this.m_listBoneScaleDef.Count; i++)
  598. {
  599. BoneScaleDef boneScaleDef = this.m_listBoneScaleDef[i];
  600. boneScaleDef.trTarget.localScale = Vector3.one;
  601. }
  602. }
  603. Transform transform = this.m_aryCapsuleBoneTrs[0];
  604. Transform transform2 = this.m_aryCapsuleBoneTrs[1];
  605. Transform transform3 = this.m_aryCapsuleBoneTrs[4];
  606. Transform transform4 = this.m_aryCapsuleBoneTrs[5];
  607. Vector3 vector = transform.position;
  608. Vector3 vector2 = transform3.position;
  609. Vector3 position = transform2.position;
  610. Vector3 position2 = transform4.position;
  611. Plane plane = new Plane(vector, position2, position);
  612. bool flag;
  613. if (!plane.GetSide(vector2))
  614. {
  615. flag = false;
  616. float distanceToPoint = plane.GetDistanceToPoint(vector2);
  617. Vector3 vector3 = vector2 - plane.normal.normalized * distanceToPoint;
  618. vector2 = vector3;
  619. }
  620. else
  621. {
  622. Plane plane2 = new Plane(vector2, position2, position);
  623. flag = true;
  624. float distanceToPoint2 = plane2.GetDistanceToPoint(vector);
  625. Vector3 vector4 = vector - plane2.normal.normalized * distanceToPoint2;
  626. vector = vector4;
  627. }
  628. Vector3 a = transform2.position - vector;
  629. Vector3 a2 = transform4.position - vector2;
  630. int num = 1;
  631. int num2 = num * 2;
  632. Vector3 a3 = a * (1f / (float)num);
  633. Vector3 a4 = a2 * (1f / (float)num);
  634. if (this.m_aryLegSegPory == null || this.m_aryLegSegPory.Length != num2 * 3)
  635. {
  636. this.m_aryLegSegPory = new Vector3[num2 * 3];
  637. this.m_aryLegSegPoryVec = new Vector3[num2 * 2];
  638. this.m_aryLegSegPlane = new Plane[num2];
  639. }
  640. for (int j = 0; j < num; j++)
  641. {
  642. Vector3 vector5 = vector + a3 * (float)j;
  643. Vector3 vector6 = vector2 + a4 * (float)j;
  644. Vector3 vector7 = vector + a3 * (float)(j + 1);
  645. Vector3 vector8 = vector2 + a4 * (float)(j + 1);
  646. if (flag)
  647. {
  648. this.m_aryLegSegPory[6 * j] = vector5;
  649. this.m_aryLegSegPory[6 * j + 1] = vector6;
  650. this.m_aryLegSegPory[6 * j + 2] = vector7;
  651. this.m_aryLegSegPoryVec[4 * j] = vector6 - vector5;
  652. this.m_aryLegSegPoryVec[4 * j + 1] = vector7 - vector5;
  653. this.m_aryLegSegPlane[2 * j].Set3Points(vector7, vector6, vector5);
  654. this.m_aryLegSegPory[6 * j + 3] = vector6;
  655. this.m_aryLegSegPory[6 * j + 4] = vector8;
  656. this.m_aryLegSegPory[6 * j + 5] = vector7;
  657. this.m_aryLegSegPoryVec[4 * j + 2] = vector8 - vector6;
  658. this.m_aryLegSegPoryVec[4 * j + 3] = vector7 - vector6;
  659. this.m_aryLegSegPlane[2 * j + 1].Set3Points(vector7, vector8, vector6);
  660. }
  661. else
  662. {
  663. this.m_aryLegSegPory[6 * j] = vector5;
  664. this.m_aryLegSegPory[6 * j + 1] = vector6;
  665. this.m_aryLegSegPory[6 * j + 2] = vector8;
  666. this.m_aryLegSegPoryVec[4 * j] = vector6 - vector5;
  667. this.m_aryLegSegPoryVec[4 * j + 1] = vector8 - vector5;
  668. this.m_aryLegSegPlane[2 * j].Set3Points(vector8, vector6, vector5);
  669. this.m_aryLegSegPory[6 * j + 3] = vector5;
  670. this.m_aryLegSegPory[6 * j + 4] = vector8;
  671. this.m_aryLegSegPory[6 * j + 5] = vector7;
  672. this.m_aryLegSegPoryVec[4 * j + 2] = vector8 - vector5;
  673. this.m_aryLegSegPoryVec[4 * j + 3] = vector7 - vector5;
  674. this.m_aryLegSegPlane[2 * j + 1].Set3Points(vector7, vector8, vector5);
  675. }
  676. }
  677. float num3 = this.m_fRegDefaultRadius;
  678. TMorph morph = this.m_Body.goSlot[0].morph;
  679. float blendValues = morph.GetBlendValues(morph.BlendDataIdx_RegFat);
  680. float blendValues2 = morph.GetBlendValues(morph.BlendDataIdx_RegMeet);
  681. float num4 = (blendValues + blendValues2) * 0.5f;
  682. if (this.m_fRegFatThrethold <= num4)
  683. {
  684. num3 *= this.m_fRegFatRateMin + (this.m_fRegFatRateMax - this.m_fRegFatRateMin) * (num4 - this.m_fRegFatThrethold);
  685. }
  686. float num5 = 0f;
  687. this.m_fEasingScale = Mathf.SmoothDamp(this.m_fEasingScale, this.m_fScaleTo, ref num5, this.m_fScaleEaseSpeed);
  688. float num6 = 0f;
  689. for (int k = 0; k < this.m_nHookBoneCount; k++)
  690. {
  691. float num7 = 0f;
  692. float num8 = 0f;
  693. Transform transform5 = this.m_aryPanierBoneTrs[k];
  694. Transform transform6 = transform5;
  695. Vector3 position3 = transform6.position;
  696. Vector3 up = transform6.up;
  697. Transform transform7 = transform5;
  698. transform5.localRotation = this.m_aryPanierBoneDefRot[k];
  699. int num9 = k;
  700. int num10 = 0;
  701. Transform transform8 = transform5;
  702. while (transform8.childCount != 0)
  703. {
  704. int num11 = (num10 + 1) * this.m_nHookBoneCount + k;
  705. Transform transform9 = this.m_aryPanierBoneTrs[num11];
  706. transform9.localRotation = this.m_aryPanierBoneDefRot[num11];
  707. transform8 = (transform7 = transform9);
  708. num10++;
  709. }
  710. if (this.m_bEnableStressScale)
  711. {
  712. transform5.localScale = new Vector3(this.m_fEasingScale, this.m_fEasingScale, this.m_fEasingScale);
  713. this.m_aryBoneTrs[k].localScale = new Vector3(this.m_fEasingScale, this.m_fEasingScale, this.m_fEasingScale);
  714. }
  715. else
  716. {
  717. transform5.localScale = Vector3.one;
  718. this.m_aryBoneTrs[k].localScale = Vector3.one;
  719. }
  720. Vector3 vector9 = transform6.position + transform6.TransformVector(Vector3.right);
  721. this.m_fPanierVecAngle[k] = 0f;
  722. for (int l = 0; l < num2; l++)
  723. {
  724. float d = 0f;
  725. float distanceToPoint3 = this.m_aryLegSegPlane[l].GetDistanceToPoint(position3);
  726. if (-this.m_fAdjustRegSegPoly < distanceToPoint3 && distanceToPoint3 < this.m_fAdjustRegSegPoly)
  727. {
  728. Vector3 b;
  729. if (distanceToPoint3 < 0f)
  730. {
  731. b = this.m_aryLegSegPlane[l].normal * this.m_fAdjustRegSegPoly;
  732. }
  733. else
  734. {
  735. b = this.m_aryLegSegPlane[l].normal * -this.m_fAdjustRegSegPoly;
  736. }
  737. if (flag)
  738. {
  739. this.m_aryLegSegPory[l * 3] += b;
  740. this.m_aryLegSegPory[l * 3 + 1] += b;
  741. this.m_aryLegSegPory[l * 3 + 2] += b;
  742. this.m_aryLegSegPlane[l].Set3Points(this.m_aryLegSegPory[l * 3 + 2], this.m_aryLegSegPory[l * 3 + 1], this.m_aryLegSegPory[l * 3]);
  743. }
  744. else
  745. {
  746. this.m_aryLegSegPory[l * 3] += b;
  747. this.m_aryLegSegPory[l * 3 + 1] += b;
  748. this.m_aryLegSegPory[l * 3 + 2] += b;
  749. this.m_aryLegSegPlane[l].Set3Points(this.m_aryLegSegPory[l * 3 + 2], this.m_aryLegSegPory[l * 3 + 1], this.m_aryLegSegPory[l * 3]);
  750. }
  751. }
  752. Vector3 tvec = position3 - this.m_aryLegSegPory[l * 3];
  753. if (MathCM.TriangleLineIntersect(position3, vector9, tvec, this.m_aryLegSegPory[l * 3], this.m_aryLegSegPoryVec[l * 2], this.m_aryLegSegPoryVec[l * 2 + 1], ref d))
  754. {
  755. this.m_fPanierVecAngle[k] = 1f;
  756. Vector3 a5 = vector9;
  757. Vector3 b2 = (a5 - position3).normalized * d;
  758. Vector3 a6 = position3 + b2;
  759. transform6.Rotate(-Vector3.forward, 1f, Space.Self);
  760. float d2 = 0f;
  761. Vector3 a7 = position3 + transform6.TransformVector(Vector3.right);
  762. Vector3 direction = a7 - position3;
  763. if (this.m_aryLegSegPlane[l].Raycast(new Ray(position3, direction), out d2))
  764. {
  765. this.m_fPanierVecAngle[k] = 2f;
  766. Vector3 vector10 = position3 + direction.normalized * d2;
  767. Vector3 vector11 = a6 - vector10;
  768. Vector3 zero = Vector3.zero;
  769. if (MathCM.SphireRayIntersect(vector10 + vector11.normalized * 10f, -vector11.normalized, position3, (position3 - transform7.position).magnitude, ref zero))
  770. {
  771. this.m_fPanierVecAngle[k] = 3f;
  772. float num12 = Vector3.Angle(zero - position3, transform7.position - position3);
  773. transform6.Rotate(-Vector3.forward, num12 + 1f);
  774. num8 += num12 + 1f;
  775. break;
  776. }
  777. }
  778. }
  779. }
  780. num10 = 0;
  781. while (transform5.childCount != 0)
  782. {
  783. int num13 = (num10 + 1) * this.m_nHookBoneCount + k;
  784. Transform transform9 = this.m_aryPanierBoneTrs[num13];
  785. bool flag2 = false;
  786. float num14 = 10f;
  787. for (int m = 0; m < this.m_listBodyBall.Count; m++)
  788. {
  789. DynamicBoneCollider dynamicBoneCollider = this.m_listBodyBall[m] as DynamicBoneCollider;
  790. Transform transform10 = dynamicBoneCollider.transform;
  791. float lossyScale = dynamicBoneCollider.GetLossyScale();
  792. float num15 = this.m_aryPanierRadius[num13];
  793. Vector3 position4 = transform9.position;
  794. float magnitude = (transform10.position - transform9.position).magnitude;
  795. if (dynamicBoneCollider.Collide(ref position4, num15))
  796. {
  797. flag2 = true;
  798. for (float num16 = 0f; num16 < 360f; num16 += 1f)
  799. {
  800. transform5.Rotate(-Vector3.forward, 1f, Space.Self);
  801. position4 = transform9.position;
  802. num8 += 1f;
  803. magnitude = (transform10.position - transform9.position).magnitude;
  804. if (!dynamicBoneCollider.Collide(ref position4, num15))
  805. {
  806. break;
  807. }
  808. }
  809. }
  810. if (magnitude - (lossyScale + num15) < num14)
  811. {
  812. num14 = magnitude - (lossyScale + num15);
  813. }
  814. }
  815. bool flag3 = false;
  816. for (int n = 0; n < this.m_nBodyCapsuleCount; n++)
  817. {
  818. float num17 = this.m_fRegDefaultRadius;
  819. if (n == 0 || n == 2)
  820. {
  821. num17 = num3;
  822. }
  823. this.m_aryBodyCapsuleRadius[n] = num17;
  824. Transform transform11 = this.m_aryCapsuleBoneTrs[2 * n];
  825. Transform transform12 = this.m_aryCapsuleBoneTrs[2 * n + 1];
  826. MathCM.Segment segment = new MathCM.Segment(transform11.position, transform12.position);
  827. float num18 = this.m_aryPanierRadius[num13];
  828. Vector3 position5 = transform9.position;
  829. Vector3 vector12;
  830. float num20;
  831. float num19 = MathCM.calcPointSegmentDist(ref position5, ref segment, out vector12, out num20);
  832. if (num19 < num17 + num18)
  833. {
  834. flag2 = (flag3 = true);
  835. Vector3 position6 = transform5.position;
  836. float num21 = 0f;
  837. float num22;
  838. for (num22 = 0f; num22 < 360f; num22 += 1f)
  839. {
  840. transform5.Rotate(-Vector3.forward, 1f, Space.Self);
  841. position5 = transform9.position;
  842. num21 += 1f;
  843. num8 += 1f;
  844. if (MathCM.calcPointSegmentDist(ref position5, ref segment, out vector12, out num20) > num17 + num18)
  845. {
  846. this.m_aryPanierBoneBeforeRotAngle[num9] = num21;
  847. break;
  848. }
  849. }
  850. if (358f <= num22)
  851. {
  852. if (this.m_bGizmoDraw)
  853. {
  854. Debug.DrawLine(transform5.position, transform9.position, Color.red);
  855. }
  856. transform5.Rotate(-Vector3.forward, this.m_aryPanierBoneBeforeRotAngle[num9], Space.Self);
  857. }
  858. }
  859. if (num19 - (num17 + num18) < num14)
  860. {
  861. num14 = num19 - (num17 + num18);
  862. }
  863. }
  864. if (!flag3)
  865. {
  866. this.m_aryPanierBoneBeforeRotAngle[num9] = 0f;
  867. }
  868. if (!flag2)
  869. {
  870. float num23 = this.m_fPanierForce;
  871. if (this.m_PanierForceDistrib != null && this.m_PanierForceDistrib.length != 0)
  872. {
  873. num23 *= this.m_PanierForceDistrib.Evaluate(this.m_aryBoneLengthRate[num13]);
  874. }
  875. this.m_aryPanierForce[num13] = num23;
  876. if (0f < this.m_fPanierForceDistanceThreshold && num14 <= this.m_fPanierForceDistanceThreshold)
  877. {
  878. this.m_aryPanierForce[num13] += (1f - num23) * (1f - num14 / this.m_fPanierForceDistanceThreshold) * this.m_fPanierStressForce;
  879. }
  880. }
  881. else
  882. {
  883. this.m_aryPanierForce[num13] = 1f * this.m_fPanierStressForce;
  884. }
  885. num7 += num8;
  886. num8 = 0f;
  887. Quaternion quaternion = this.m_aryPanierBoneDefRot[num13];
  888. num9 = num13;
  889. transform5 = transform9;
  890. num10++;
  891. }
  892. if (this.m_bEnableLegSegHit)
  893. {
  894. for (int num24 = 0; num24 < num2; num24++)
  895. {
  896. float d3 = 0f;
  897. Vector3 tvec2 = position3 - this.m_aryLegSegPory[num24 * 3];
  898. if (MathCM.TriangleLineIntersect(position3, transform7.position, tvec2, this.m_aryLegSegPory[num24 * 3], this.m_aryLegSegPoryVec[num24 * 2], this.m_aryLegSegPoryVec[num24 * 2 + 1], ref d3))
  899. {
  900. Vector3 position7 = transform7.position;
  901. Vector3 b3 = (position7 - position3).normalized * d3;
  902. Vector3 a8 = position3 + b3;
  903. transform6.Rotate(-Vector3.forward, 1f, Space.Self);
  904. float d4 = 0f;
  905. Vector3 direction2 = transform7.position - position3;
  906. if (this.m_aryLegSegPlane[num24].Raycast(new Ray(position3, direction2), out d4))
  907. {
  908. Vector3 vector13 = position3 + direction2.normalized * d4;
  909. Vector3 vector14 = a8 - vector13;
  910. Vector3 zero2 = Vector3.zero;
  911. if (MathCM.SphireRayIntersect(vector13 - vector14.normalized * 10f, vector14.normalized, position3, (position3 - position7).magnitude, ref zero2))
  912. {
  913. float num25 = Vector3.Angle(zero2 - position3, position7 - position3);
  914. transform6.Rotate(-Vector3.forward, num25 + 1f);
  915. num7 += num25 + 1f;
  916. break;
  917. }
  918. }
  919. }
  920. }
  921. }
  922. this.m_fPanierStress[k] = num7;
  923. if (num6 < num7)
  924. {
  925. num6 = num7;
  926. }
  927. }
  928. if (this.m_fStressDgreeMin < num6)
  929. {
  930. float num26 = Mathf.Clamp(num6, this.m_fStressDgreeMin, this.m_fStressDgreeMax);
  931. this.m_fScaleTo = 1f - (1f - this.m_fStressMinScale) * ((num26 - this.m_fStressDgreeMin) / (this.m_fStressDgreeMax - this.m_fStressDgreeMin));
  932. }
  933. else
  934. {
  935. this.m_fScaleTo = 1f;
  936. }
  937. for (int num27 = 0; num27 < this.m_nHookBoneCount; num27++)
  938. {
  939. Vector3 position8 = this.m_listHookBoneTrs[num27].position;
  940. this.m_aryHookBonePos[3 * num27] = position8.x;
  941. this.m_aryHookBonePos[3 * num27 + 1] = position8.y;
  942. this.m_aryHookBonePos[3 * num27 + 2] = position8.z;
  943. }
  944. for (int num28 = 0; num28 < this.m_aryPanierBoneTrs.Length; num28++)
  945. {
  946. Transform transform13 = this.m_aryPanierBoneTrs[num28].transform;
  947. this.m_aryPanierBonePos[3 * num28] = transform13.position.x;
  948. this.m_aryPanierBonePos[3 * num28 + 1] = transform13.position.y;
  949. this.m_aryPanierBonePos[3 * num28 + 2] = transform13.position.z;
  950. }
  951. if (GameMain.Instance.VRMode)
  952. {
  953. Transform transform14 = GameMain.Instance.OvrMgr.GetVRControllerTransform(true).transform;
  954. Transform transform15 = GameMain.Instance.OvrMgr.GetVRControllerTransform(false).transform;
  955. AVRControllerButtons vrcontrollerButtons = GameMain.Instance.OvrMgr.GetVRControllerButtons(true);
  956. AVRControllerButtons vrcontrollerButtons2 = GameMain.Instance.OvrMgr.GetVRControllerButtons(false);
  957. Func<int, Transform, AVRControllerButtons, int> func = delegate(int grabIdx, Transform handTrans, AVRControllerButtons handBtns)
  958. {
  959. if (grabIdx == -1)
  960. {
  961. for (int num51 = 0; num51 < this.m_nHookBoneCount; num51++)
  962. {
  963. int num52 = this.m_nBoneCount / this.m_nHookBoneCount;
  964. for (int num53 = 0; num53 < num52; num53++)
  965. {
  966. int num54 = num51 + num53 * this.m_nHookBoneCount;
  967. Transform transform21 = this.m_aryBoneTrs[num54];
  968. if (handBtns.GetPressDown(AVRControllerButtons.BTN.VIRTUAL_GRUB) && (transform21.position - handTrans.position).magnitude < 0.2f)
  969. {
  970. grabIdx = num54;
  971. break;
  972. }
  973. }
  974. }
  975. }
  976. else if (handBtns.GetPress(AVRControllerButtons.BTN.VIRTUAL_GRUB))
  977. {
  978. for (int num55 = grabIdx; num55 < this.m_nBoneCount; num55 += this.m_nHookBoneCount)
  979. {
  980. this.m_aryPanierForce[num55] = 0f;
  981. }
  982. Vector3 position9 = handTrans.position;
  983. this.m_aryPanierBonePos[3 * grabIdx] = position9.x;
  984. this.m_aryPanierBonePos[3 * grabIdx + 1] = position9.y;
  985. this.m_aryPanierBonePos[3 * grabIdx + 2] = position9.z;
  986. this.m_aryPanierForce[grabIdx] = 1f;
  987. Transform transform22 = this.m_aryBoneTrs[grabIdx];
  988. for (int num56 = 0; num56 < this.m_nHookBoneCount; num56++)
  989. {
  990. int num57 = this.m_nBoneCount / this.m_nHookBoneCount;
  991. for (int num58 = 0; num58 < num57; num58++)
  992. {
  993. int num59 = num56 + num58 * this.m_nHookBoneCount;
  994. if (grabIdx != num59)
  995. {
  996. Transform transform23 = this.m_aryBoneTrs[num59];
  997. float magnitude4 = (transform22.position - transform23.position).magnitude;
  998. if (magnitude4 <= 0.5f)
  999. {
  1000. this.m_aryPanierForce[num59] *= magnitude4 / 0.5f;
  1001. }
  1002. }
  1003. }
  1004. }
  1005. Debug.DrawLine(this.m_aryBoneTrs[grabIdx].position, this.m_aryBoneTrs[grabIdx].position + Vector3.up, Color.red);
  1006. }
  1007. else
  1008. {
  1009. grabIdx = -1;
  1010. }
  1011. return grabIdx;
  1012. };
  1013. this.m_nGrabIdxLeft = func(this.m_nGrabIdxLeft, transform14, vrcontrollerButtons);
  1014. this.m_nGrabIdxRight = func(this.m_nGrabIdxRight, transform15, vrcontrollerButtons2);
  1015. }
  1016. for (int num29 = 0; num29 < this.m_nBodyBallCount; num29++)
  1017. {
  1018. Transform transform16 = this.m_listBodyBallPos[num29];
  1019. this.m_aryBodyBallPos[3 * num29] = transform16.position.x;
  1020. this.m_aryBodyBallPos[3 * num29 + 1] = transform16.position.y;
  1021. this.m_aryBodyBallPos[3 * num29 + 2] = transform16.position.z;
  1022. }
  1023. for (int num30 = 0; num30 < this.m_nBodyCapsuleCount; num30++)
  1024. {
  1025. this.m_aryBodyCapsulePos[6 * num30] = this.m_aryCapsuleBoneTrs[2 * num30].position.x;
  1026. this.m_aryBodyCapsulePos[6 * num30 + 1] = this.m_aryCapsuleBoneTrs[2 * num30].position.y;
  1027. this.m_aryBodyCapsulePos[6 * num30 + 2] = this.m_aryCapsuleBoneTrs[2 * num30].position.z;
  1028. this.m_aryBodyCapsulePos[6 * num30 + 3] = this.m_aryCapsuleBoneTrs[2 * num30 + 1].position.x;
  1029. this.m_aryBodyCapsulePos[6 * num30 + 4] = this.m_aryCapsuleBoneTrs[2 * num30 + 1].position.y;
  1030. this.m_aryBodyCapsulePos[6 * num30 + 5] = this.m_aryCapsuleBoneTrs[2 * num30 + 1].position.z;
  1031. }
  1032. Vector3 vector15 = this.m_Body.Pelvis.TransformPoint(new Vector3(-1f, 0f, 0f));
  1033. this.m_vLegPelvisToSpine[0] = vector15.x;
  1034. this.m_vLegPelvisToSpine[1] = vector15.y;
  1035. this.m_vLegPelvisToSpine[2] = vector15.z;
  1036. Vector3 vector16 = this.m_Body.Pelvis.TransformPoint(new Vector3(0f, 1f, 0f)) - this.m_Body.Pelvis.position;
  1037. this.m_vLegPelvisToSpine[3] = vector16.x;
  1038. this.m_vLegPelvisToSpine[4] = vector16.y;
  1039. this.m_vLegPelvisToSpine[5] = vector16.z;
  1040. this.m_aryLegSeqRadius[0] = this.m_fLegSeqRad0;
  1041. this.m_aryLegSeqRadius[1] = this.m_fLegSeqRad1;
  1042. this.m_aryLegSeqRadius[2] = this.m_fLegSeqRad1;
  1043. this.m_aryLegSeqRadius[3] = this.m_fLegSeqRad2;
  1044. this.m_aryLegSeqRadius[4] = this.m_fLegSeqRad2;
  1045. this.m_aryLegSeqRadius[5] = this.m_fLegSeqRad3;
  1046. DynamicSkirtBone.m_dgExport_GetBonePos(this.m_nDllPhysicsInstanceID, this.m_nCalcTime, this.m_aryHookBonePos, this.m_nHookBoneCount, this.m_aryPanierBonePos, this.m_nPanierBoneCount, this.m_aryBonePos, this.m_nBoneCount, this.m_aryPanierForce, this.m_nBodyBallCount, this.m_aryBodyBallPos, this.m_nBodyCapsuleCount, this.m_aryBodyCapsulePos, this.m_aryBoneNormal, this.m_aryDebugLegSeqPos, this.m_aryLegSeqRadius, this.m_vLegPelvisToSpine, this.m_aryBoneParam, this.m_aryVelocityForceRate, this.m_aryGravity, this.m_aryHard, (!this.m_bResetPos) ? 0 : 1, this.m_Body.BoneHitHeightY + this.m_fFloorOffsetY);
  1047. for (int num31 = 0; num31 < this.m_nHookBoneCount; num31++)
  1048. {
  1049. int num32 = this.m_nBoneCount / this.m_nHookBoneCount;
  1050. for (int num33 = 0; num33 < num32; num33++)
  1051. {
  1052. int num34 = num31 + num33 * this.m_nHookBoneCount;
  1053. Vector3 vector17 = new Vector3(this.m_aryBonePos[3 * num34], this.m_aryBonePos[3 * num34 + 1], this.m_aryBonePos[3 * num34 + 2]);
  1054. Transform transform17 = this.m_aryBoneTrs[num34];
  1055. if (GameMain.Instance.VRMode && GameMain.Instance.VRFamily != GameMain.VRFamilyType.NON && num33 != 0)
  1056. {
  1057. transform17.localScale = Vector3.one;
  1058. }
  1059. transform17.position = vector17;
  1060. if (num33 < num32 - 1)
  1061. {
  1062. int num35 = num31 + (num33 + 1) * this.m_nHookBoneCount;
  1063. Vector3 a9 = new Vector3(this.m_aryBonePos[3 * num35], this.m_aryBonePos[3 * num35 + 1], this.m_aryBonePos[3 * num35 + 2]);
  1064. Vector3 lhs = new Vector3(this.m_aryBoneNormal[3 * num34], this.m_aryBoneNormal[3 * num34 + 1], this.m_aryBoneNormal[3 * num34 + 2]);
  1065. Vector3 vector18 = a9 - vector17;
  1066. Vector3 vector19 = Vector3.Cross(lhs, vector18);
  1067. Quaternion rotation = Quaternion.AngleAxis(-90f, vector19);
  1068. vector18 = rotation * vector18;
  1069. transform17.rotation = Quaternion.LookRotation(vector19, vector18);
  1070. }
  1071. if (this.m_bOldBone && this.m_bPanierOldBoneRotRev[num34])
  1072. {
  1073. transform17.Rotate(this.m_vPanierOldBoneRotRevAfter[num34], Space.Self);
  1074. }
  1075. }
  1076. }
  1077. if (this.m_listBoneScaleDef.Count != 0)
  1078. {
  1079. for (int num36 = 0; num36 < this.m_listBoneScaleDef.Count; num36++)
  1080. {
  1081. BoneScaleDef boneScaleDef2 = this.m_listBoneScaleDef[num36];
  1082. boneScaleDef2.trTarget.localScale = boneScaleDef2.vDefScale;
  1083. }
  1084. }
  1085. if (GameMain.Instance.VRMode && GameMain.Instance.VRFamily != GameMain.VRFamilyType.NON)
  1086. {
  1087. CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT ovr_HAND_TO_SKIRT = GameMain.Instance.CMSystem.SConfig.OvrHandHitToSkirt;
  1088. if (OvrIK.IsModeVRIK)
  1089. {
  1090. ovr_HAND_TO_SKIRT = GameMain.Instance.CMSystem.SConfig.OvrHandHitToSkirtVAS;
  1091. }
  1092. bool flag4 = ovr_HAND_TO_SKIRT != CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.OFF;
  1093. if (flag4 && ovr_HAND_TO_SKIRT == CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.GRAB)
  1094. {
  1095. AVRControllerButtons vrcontrollerButtons3 = GameMain.Instance.OvrMgr.GetVRControllerButtons(true);
  1096. if (vrcontrollerButtons3 != null)
  1097. {
  1098. flag4 = vrcontrollerButtons3.GetPress(AVRControllerButtons.BTN.VIRTUAL_GRUB);
  1099. }
  1100. }
  1101. bool flag5 = ovr_HAND_TO_SKIRT != CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.OFF;
  1102. if (flag5 && ovr_HAND_TO_SKIRT == CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.GRAB)
  1103. {
  1104. AVRControllerButtons vrcontrollerButtons4 = GameMain.Instance.OvrMgr.GetVRControllerButtons(false);
  1105. if (vrcontrollerButtons4 != null)
  1106. {
  1107. flag5 = vrcontrollerButtons4.GetPress(AVRControllerButtons.BTN.VIRTUAL_GRUB);
  1108. }
  1109. }
  1110. Transform vrcontrollerTransform = GameMain.Instance.OvrMgr.GetVRControllerTransform(true);
  1111. Transform vrcontrollerTransform2 = GameMain.Instance.OvrMgr.GetVRControllerTransform(false);
  1112. for (int num37 = 0; num37 < this.m_nHookBoneCount; num37++)
  1113. {
  1114. float num38 = float.PositiveInfinity;
  1115. int num39 = -1;
  1116. float num40 = float.PositiveInfinity;
  1117. int num41 = -1;
  1118. int num42 = this.m_nBoneCount / this.m_nHookBoneCount;
  1119. for (int num43 = 0; num43 < num42; num43++)
  1120. {
  1121. int num44 = num37 + num43 * this.m_nHookBoneCount;
  1122. Transform transform18 = this.m_aryBoneTrs[num44];
  1123. if (flag4 && vrcontrollerTransform != null)
  1124. {
  1125. float magnitude2 = (transform18.position - vrcontrollerTransform.position).magnitude;
  1126. if (magnitude2 < num38)
  1127. {
  1128. num39 = num43;
  1129. num38 = magnitude2;
  1130. }
  1131. }
  1132. if (flag5 && vrcontrollerTransform2 != null)
  1133. {
  1134. float magnitude3 = (transform18.position - vrcontrollerTransform2.position).magnitude;
  1135. if (magnitude3 < num40)
  1136. {
  1137. num41 = num43;
  1138. num40 = magnitude3;
  1139. }
  1140. }
  1141. }
  1142. if (num39 != -1 && num38 < this.m_vrHandHitRaidus)
  1143. {
  1144. for (int num45 = 0; num45 < num42; num45++)
  1145. {
  1146. int num46 = num37 + num45 * this.m_nHookBoneCount;
  1147. Transform transform19 = this.m_aryBoneTrs[num46];
  1148. Vector3 localScale = transform19.localScale;
  1149. float num47 = (float)num39 / (float)(num42 - 1);
  1150. transform19.localScale = new Vector3(localScale.x * ((num38 + (this.m_vrHandHitRaidus - num38) * num47) / this.m_vrHandHitRaidus), localScale.y, localScale.z);
  1151. }
  1152. }
  1153. if (num41 != -1 && num40 < this.m_vrHandHitRaidus)
  1154. {
  1155. for (int num48 = 0; num48 < num42; num48++)
  1156. {
  1157. int num49 = num37 + num48 * this.m_nHookBoneCount;
  1158. Transform transform20 = this.m_aryBoneTrs[num49];
  1159. Vector3 localScale2 = transform20.localScale;
  1160. float num50 = (float)num41 / (float)(num42 - 1);
  1161. transform20.localScale = new Vector3(localScale2.x * ((num40 + (this.m_vrHandHitRaidus - num40) * num50) / this.m_vrHandHitRaidus), localScale2.y, localScale2.z);
  1162. }
  1163. }
  1164. }
  1165. }
  1166. this.m_bResetPos = false;
  1167. }
  1168. [Header("■パニエ ノードサイズ")]
  1169. public float m_fPanierRadius = 0.025f;
  1170. public AnimationCurve m_PanierRadiusDistrib;
  1171. public bool m_bPanierNodeGizmoDraw;
  1172. [Header("■パニエ ノードサイズの上書き")]
  1173. [SerializeField]
  1174. public DynamicSkirtBone.PanierRadiusGroup[] m_PanierRadiusDistribGroup;
  1175. [Header("■パニエ 力")]
  1176. [Range(0f, 1f)]
  1177. public float m_fPanierForce = 0.134f;
  1178. public AnimationCurve m_PanierForceDistrib;
  1179. public bool m_bPanierLineGizmoDraw;
  1180. [Header("■パニエ 重力適応割合(初期パニエノード回転から重力方向への力の割合)")]
  1181. [Range(0f, 1f)]
  1182. public float m_fPanierGravityRate;
  1183. [Header("■パニエ 当たっていない場合の戻る力")]
  1184. [Range(0f, 2f)]
  1185. public float m_fPanierStiffnessRate;
  1186. [Header("■パニエ 足に当っていた場合の強制パニエ力")]
  1187. [Range(0f, 1f)]
  1188. public float m_fPanierStressForce = 0.4f;
  1189. [Header("■パニエ 足との距離によるパニエ力")]
  1190. public float m_fPanierForceDistanceThreshold = 0.1f;
  1191. [Header("■パニエ 角度による全体のスケーリング")]
  1192. [Tooltip("水平方向に伸びて見えるのを防ぐ。")]
  1193. public bool m_bEnableStressScale = true;
  1194. public float m_fStressDgreeMin = 45f;
  1195. public float m_fStressDgreeMax = 90f;
  1196. public float m_fStressMinScale = 0.75f;
  1197. [ReadOnly]
  1198. public float m_fScaleTo = 1f;
  1199. [ReadOnly]
  1200. public float m_fEasingScale = 1f;
  1201. public float m_fScaleEaseSpeed = 5f;
  1202. [ReadOnly]
  1203. public float[] m_fPanierStress;
  1204. [ReadOnly]
  1205. public float[] m_fPanierVecAngle;
  1206. [Header("■パニエ 足の間の当たり判定")]
  1207. public bool m_bEnableLegSegHit = true;
  1208. public float m_fLegSegHitDgree = 45f;
  1209. [Header("■パニエ 足側カプセル初期半径")]
  1210. public float m_fRegDefaultRadius = 0.1f;
  1211. [Header("■パニエ 腿判定の足の太さによる補正 掛け算")]
  1212. public bool m_bEnableRegFatAndMeetAdjust = true;
  1213. public float m_fRegFatThrethold = 0.5f;
  1214. public float m_fRegFatRateMin = 1f;
  1215. public float m_fRegFatRateMax = 1.3f;
  1216. [Header("■パニエ 股間ポリゴン判定 親自体がポリゴンに近接している場合のポリゴン位置補正")]
  1217. public float m_fAdjustRegSegPoly = 0.005f;
  1218. [Header("■物理 計算回数")]
  1219. public int m_nCalcTime = 16;
  1220. [Header("■物理 惰性割合")]
  1221. public float m_fVelocityForceRate = 0.8f;
  1222. public AnimationCurve m_VelocityForceRateDistrib;
  1223. [Header("■物理 重力")]
  1224. public Vector3 m_vGravity = new Vector3(0f, -0.005f, 0f);
  1225. public AnimationCurve m_GravityDistrib;
  1226. [Header("■物理 繋がり力(横縮,横伸,縦縮,縦伸)(物理計算回数に依存)")]
  1227. public float[] m_aryHard = new float[]
  1228. {
  1229. 0f,
  1230. 0.01f,
  1231. 0f,
  1232. 0.7f
  1233. };
  1234. [Header("■物理 床判定オフセット")]
  1235. public float m_fFloorOffsetY = -0.03f;
  1236. public bool m_RealBoneAndNormalGizmoDraw = true;
  1237. [Header("")]
  1238. public float m_fLegSeqRad0 = 0.1f;
  1239. public float m_fLegSeqRad1 = 0.1f;
  1240. public float m_fLegSeqRad2 = 0.1f;
  1241. public float m_fLegSeqRad3 = 0.1f;
  1242. [Header("")]
  1243. public bool m_bGizmoDraw = true;
  1244. public bool m_bResetPos;
  1245. [Header("VR手のスカートへの当たり判定")]
  1246. public float m_vrHandHitRaidus = 0.2f;
  1247. public const int SKIRT_W_MAX = 24;
  1248. public const int SKIRT_H_MAX = 48;
  1249. private Transform[] m_aryBoneTrs = new Transform[1152];
  1250. private float[] m_aryBonePos = new float[6144];
  1251. private int m_nBoneCount;
  1252. private int[] m_aryBoneParam = new int[2048];
  1253. private float[] m_aryBoneLength = new float[1152];
  1254. private float[] m_aryBoneLengthRate = new float[1152];
  1255. private float[] m_aryBoneNormal = new float[6144];
  1256. private Transform m_trPanierParent;
  1257. private float[] m_aryPanierBonePos = new float[6144];
  1258. private int m_nPanierBoneCount;
  1259. private Transform[] m_aryPanierBoneTrs;
  1260. private Transform[] m_aryPanierPanierBoneTrs;
  1261. private float[] m_aryPanierForce;
  1262. private Quaternion[] m_aryPanierBoneDefRot;
  1263. private float[] m_aryPanierBoneToLegSegRate;
  1264. private float[] m_aryPanierBoneBeforeRotAngle;
  1265. private bool[] m_bPanierOldBoneRotRev;
  1266. private Vector3[] m_vPanierOldBoneRotRevInit;
  1267. private Vector3[] m_vPanierOldBoneRotRevAfter;
  1268. private Transform[] m_aryPanierLastChildDef;
  1269. private float[] m_aryPanierRadius;
  1270. private float[] m_aryVelocityForceRate;
  1271. private float[] m_aryGravity;
  1272. private List<Transform> m_listHookBoneTrs;
  1273. private float[] m_aryHookBonePos = new float[6144];
  1274. private int m_nHookBoneCount;
  1275. private List<Transform> m_listBodyBallPos = new List<Transform>();
  1276. private float[] m_aryBodyBallPos = new float[6144];
  1277. private float[] m_aryBodyBallRadius = new float[2048];
  1278. private int m_nBodyBallCount;
  1279. public List<DynamicBoneColliderBase> m_listBodyBall = new List<DynamicBoneColliderBase>();
  1280. private Transform[] m_aryCapsuleBoneTrs;
  1281. private float[] m_aryBodyCapsulePos = new float[12288];
  1282. private float[] m_aryBodyCapsuleRadius = new float[2048];
  1283. private int m_nBodyCapsuleCount;
  1284. private float[] m_aryDebugLegSeqPos = new float[120];
  1285. private float[] m_vLegPelvisToSpine = new float[6];
  1286. private float[] m_aryLegSeqRadius = new float[20];
  1287. private TBody m_Body;
  1288. private TBodySkin m_BodySkin;
  1289. private Transform[] m_aryTestCapsule;
  1290. private List<BoneScaleDef> m_listBoneScaleDef = new List<BoneScaleDef>();
  1291. private bool m_bOldBone;
  1292. private const string kUseDllPath_x64 = "Plugins/";
  1293. private static IntPtr m_PluginDll = IntPtr.Zero;
  1294. private List<GCHandle> m_listGcHandle = new List<GCHandle>();
  1295. private int m_nDllPhysicsInstanceID = -1;
  1296. private static DynamicSkirtBone.Export_PhysicsCreate m_dgExport_PhysicsCreate = null;
  1297. private static DynamicSkirtBone.Export_PhysicsDelete m_dgExport_PhysicsDelete = null;
  1298. private static DynamicSkirtBone.Export_InitSkirt m_dgExport_InitSkirt = null;
  1299. private static DynamicSkirtBone.Export_GetBonePos m_dgExport_GetBonePos = null;
  1300. private GameObject m_point;
  1301. private GameObject m_capsule;
  1302. private float m_fMaxLenght;
  1303. private Vector3 m_testLineA;
  1304. private Transform m_testGoRay;
  1305. private Transform m_testGoTriA;
  1306. private Transform m_testGoTriB;
  1307. private Transform m_testGoTriC;
  1308. private Vector3[] m_aryLegSegPory;
  1309. private Vector3[] m_aryLegSegPoryVec;
  1310. private Plane[] m_aryLegSegPlane;
  1311. private int m_nGrabIdxLeft = -1;
  1312. private int m_nGrabIdxRight = -1;
  1313. private Vector3 m_vGrabPos = Vector3.zero;
  1314. private float m_grabDistance;
  1315. [Serializable]
  1316. public class PanierRadiusGroup
  1317. {
  1318. [SerializeField]
  1319. public string strBoneName;
  1320. [SerializeField]
  1321. public float fRadius;
  1322. [SerializeField]
  1323. public AnimationCurve Curve;
  1324. }
  1325. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  1326. private delegate int Export_PhysicsCreate();
  1327. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  1328. private delegate void Export_PhysicsDelete(int f_nID);
  1329. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  1330. private delegate void Export_InitSkirt(int f_nID, float f_fHardHShort, float f_fHardHLong, float f_HardVShort, float f_HardVLong, float[] f_aryBonePos, int f_nBoneCount, int f_nSWidth, int f_nBallCount, float[] f_aryBallPos, float[] f_aryBallRadius, int f_nCapsuleCount, float[] f_aryCapsulePos, float[] f_aryCapsuleRadius, float[] f_vLegPelvisToSpine, float[] f_aryLegSeqRadius);
  1331. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  1332. private delegate void Export_GetBonePos(int f_nID, int f_nCalcTime, float[] f_aryHookBonePos, int f_nHookBoneCount, float[] f_aryPanierBonePos, int f_nPanierBoneCount, float[] f_aryBonePos, int f_nBoneCount, float[] f_aryPanierForce, int f_nBallCount, float[] f_aryBallPos, int f_nCapsuleCount, float[] f_aryCapsulePos, float[] f_aryNodeNormal, float[] f_aryDebugLegSeqPos, float[] f_aryLegSeqRadius, float[] f_aryLegPelvisToSpine, int[] f_aryBoneParam, float[] f_aryVelocityForceRate, float[] f_aryGravity, float[] f_aryHard, int f_bReset, float f_fFloorY);
  1333. }