BaseClothAPI.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. // Magica Cloth.
  2. // Copyright (c) MagicaSoft, 2020-2022.
  3. // https://magicasoft.jp
  4. using UnityEngine;
  5. namespace MagicaCloth
  6. {
  7. /// <summary>
  8. /// BaseCloth API
  9. /// </summary>
  10. public abstract partial class BaseCloth : PhysicsTeam
  11. {
  12. /// <summary>
  13. /// クロスの物理シミュレーションをリセットします
  14. /// Reset cloth physics simulation.
  15. /// </summary>
  16. public void ResetCloth()
  17. {
  18. ResetClothInternal(clothParams.TeleportResetMode, -1.0f);
  19. }
  20. /// <summary>
  21. /// クロスの物理シミュレーションをリセットします
  22. /// Reset cloth physics simulation.
  23. /// </summary>
  24. /// <param name="resetStabilizationTime">Time to stabilize simulation (s)</param>
  25. public void ResetCloth(float resetStabilizationTime)
  26. {
  27. ResetClothInternal(clothParams.TeleportResetMode, Mathf.Max(resetStabilizationTime, 0.0f));
  28. }
  29. /// <summary>
  30. /// クロスの物理シミュレーションをリセットします
  31. /// Reset cloth physics simulation.
  32. /// </summary>
  33. /// <param name="teleportMode">RESET...Resets all simulations. KEEP...Keep the simulation.</param>
  34. /// <param name="resetStabilizationTime">Time to stabilize simulation(s).If negative, the time set in the inspector.</param>
  35. public void ResetCloth(ClothParams.TeleportMode teleportMode, float resetStabilizationTime = -1.0f)
  36. {
  37. ResetClothInternal(teleportMode, resetStabilizationTime);
  38. }
  39. /// <summary>
  40. /// タイムスケールを変更します
  41. /// Change the time scale.
  42. /// </summary>
  43. /// <param name="timeScale">0.0-1.0</param>
  44. public void SetTimeScale(float timeScale)
  45. {
  46. if (IsValid())
  47. MagicaPhysicsManager.Instance.Team.SetTimeScale(teamId, Mathf.Clamp01(timeScale));
  48. }
  49. /// <summary>
  50. /// タイムスケールを取得します
  51. /// Get the time scale.
  52. /// </summary>
  53. /// <returns></returns>
  54. public float GetTimeScale()
  55. {
  56. if (IsValid())
  57. return MagicaPhysicsManager.Instance.Team.GetTimeScale(teamId);
  58. else
  59. return 1.0f;
  60. }
  61. /// <summary>
  62. /// 外力を与えます
  63. /// Add external force.
  64. /// </summary>
  65. /// <param name="force"></param>
  66. public void AddForce(Vector3 force, PhysicsManagerTeamData.ForceMode mode)
  67. {
  68. if (IsValid() && IsActive())
  69. MagicaPhysicsManager.Instance.Team.SetImpactForce(teamId, force, mode);
  70. }
  71. /// <summary>
  72. /// 元の姿勢とシミュレーション結果とのブレンド率
  73. /// Blend ratio between original posture and simulation result.
  74. /// (0.0 = 0%, 1.0 = 100%)
  75. /// </summary>
  76. public float BlendWeight
  77. {
  78. get
  79. {
  80. return UserBlendWeight;
  81. }
  82. set
  83. {
  84. UserBlendWeight = value;
  85. }
  86. }
  87. /// <summary>
  88. /// コライダーをチームに追加します
  89. /// Add collider to the team.
  90. /// </summary>
  91. /// <param name="collider"></param>
  92. public void AddCollider(ColliderComponent collider)
  93. {
  94. Init(); // チームが初期化されていない可能性があるので.
  95. if (IsValid() && collider)
  96. {
  97. var c = collider.CreateColliderParticle(teamId);
  98. if (c.IsValid())
  99. TeamData.AddCollider(collider);
  100. }
  101. }
  102. /// <summary>
  103. /// コライダーをチームから削除します
  104. /// Remove collider from the team.
  105. /// </summary>
  106. /// <param name="collider"></param>
  107. public void RemoveCollider(ColliderComponent collider)
  108. {
  109. if (IsValid() && collider)
  110. {
  111. collider.RemoveColliderParticle(teamId);
  112. TeamData.RemoveCollider(collider);
  113. }
  114. }
  115. /// <summary>
  116. /// 更新モードを変更します
  117. /// Change the update mode.
  118. /// </summary>
  119. /// <param name="updateMode"></param>
  120. public void SetUpdateMode(TeamUpdateMode updateMode)
  121. {
  122. UpdateMode = updateMode;
  123. }
  124. /// <summary>
  125. /// カリングモードを変更します
  126. /// Change the culling mode.
  127. /// </summary>
  128. /// <param name="cullingMode"></param>
  129. public void SetCullingMode(TeamCullingMode cullingMode)
  130. {
  131. CullingMode = cullingMode;
  132. }
  133. //=========================================================================================
  134. // [Radius] Parameters access.
  135. //=========================================================================================
  136. /// <summary>
  137. /// パーティクル半径の設定
  138. /// Setting up a particle radius.
  139. /// </summary>
  140. /// <param name="startVal">0.001 ~ </param>
  141. /// <param name="endVal">0.001 ~ </param>
  142. /// <param name="curveVal">-1.0 ~ +1.0</param>
  143. public void Radius_SetRadius(float startVal, float endVal, float curveVal = 0)
  144. {
  145. var b = clothParams.GetRadius().AutoSetup(Mathf.Max(startVal, 0.001f), Mathf.Max(endVal, 0.001f), curveVal);
  146. // update team particles.
  147. var manager = MagicaPhysicsManager.Instance;
  148. for (int i = 0; i < ParticleChunk.dataLength; i++)
  149. {
  150. int pindex = ParticleChunk.startIndex + i;
  151. float depth = manager.Particle.depthList[pindex];
  152. float radius = b.Evaluate(depth);
  153. manager.Particle.SetRadius(pindex, radius);
  154. }
  155. }
  156. //=========================================================================================
  157. // [Mass] Parameters access.
  158. //=========================================================================================
  159. /// <summary>
  160. /// 重量の設定
  161. /// Setting up a mass.
  162. /// </summary>
  163. /// <param name="startVal">1.0 ~ </param>
  164. /// <param name="endVal">1.0 ~ </param>
  165. /// <param name="curveVal">-1.0 ~ +1.0</param>
  166. public void Mass_SetMass(float startVal, float endVal, float curveVal = 0)
  167. {
  168. var b = clothParams.GetMass().AutoSetup(Mathf.Max(startVal, 1.0f), Mathf.Max(endVal, 1.0f), curveVal);
  169. if (IsValid())
  170. {
  171. MagicaPhysicsManager.Instance.Team.SetMass(TeamId, b);
  172. // Parameters related to mass
  173. MagicaPhysicsManager.Instance.Compute.RestoreDistance.ChangeParam(
  174. TeamId,
  175. clothParams.GetMass(),
  176. clothParams.RestoreDistanceVelocityInfluence,
  177. clothParams.GetStructDistanceStiffness(),
  178. clothParams.UseBendDistance,
  179. clothParams.GetBendDistanceStiffness(),
  180. clothParams.UseNearDistance,
  181. clothParams.GetNearDistanceStiffness()
  182. );
  183. }
  184. }
  185. //=========================================================================================
  186. // [Clamp Position] Parameters access.
  187. //=========================================================================================
  188. /// <summary>
  189. /// 移動範囲距離の設定
  190. /// Movement range distance setting.
  191. /// </summary>
  192. /// <param name="startVal">0.0 ~ 1.0</param>
  193. /// <param name="endVal">0.0 ~ 1.0</param>
  194. /// <param name="curveVal">-1.0 ~ +1.0</param>
  195. public void ClampPosition_SetPositionLength(float startVal, float endVal, float curveVal = 0)
  196. {
  197. var b = clothParams.GetClampPositionLength().AutoSetup(Mathf.Max(startVal, 1.0f), Mathf.Max(endVal, 1.0f), curveVal);
  198. if (IsValid())
  199. {
  200. MagicaPhysicsManager.Instance.Compute.ClampPosition.ChangeParam(
  201. TeamId,
  202. clothParams.UseClampPositionLength,
  203. clothParams.GetClampPositionLength(),
  204. clothParams.ClampPositionAxisRatio,
  205. clothParams.ClampPositionVelocityInfluence
  206. );
  207. }
  208. }
  209. //=========================================================================================
  210. // [Gravity] Parameters access.
  211. //=========================================================================================
  212. /// <summary>
  213. /// 重力加速度の設定
  214. /// Setting up a gravity.
  215. /// </summary>
  216. /// <param name="startVal"></param>
  217. /// <param name="endVal"></param>
  218. /// <param name="curveVal">-1.0 ~ +1.0</param>
  219. public void Gravity_SetGravity(float startVal, float endVal, float curveVal = 0)
  220. {
  221. var b = clothParams.GetGravity().AutoSetup(startVal, endVal, curveVal);
  222. if (IsValid())
  223. {
  224. MagicaPhysicsManager.Instance.Team.SetGravity(TeamId, b);
  225. }
  226. }
  227. /// <summary>
  228. /// 重力方向の設定.天井方向を指定します.
  229. /// Gravity direction setting. Specify the ceiling direction.
  230. /// </summary>
  231. public Vector3 Gravity_GravityDirection
  232. {
  233. get
  234. {
  235. return clothParams.GravityDirection;
  236. }
  237. set
  238. {
  239. clothParams.GravityDirection = value;
  240. if (IsValid())
  241. {
  242. MagicaPhysicsManager.Instance.Team.SetGravityDirection(TeamId, value);
  243. }
  244. }
  245. }
  246. //=========================================================================================
  247. // [Drag] Parameters access.
  248. //=========================================================================================
  249. /// <summary>
  250. /// 空気抵抗の設定
  251. /// Setting up a drag.
  252. /// </summary>
  253. /// <param name="startVal">0.0 ~ 1.0</param>
  254. /// <param name="endVal">0.0 ~ 1.0</param>
  255. /// <param name="curveVal">-1.0 ~ +1.0</param>
  256. public void Drag_SetDrag(float startVal, float endVal, float curveVal = 0)
  257. {
  258. var b = clothParams.GetDrag().AutoSetup(startVal, endVal, curveVal);
  259. if (IsValid())
  260. {
  261. MagicaPhysicsManager.Instance.Team.SetDrag(TeamId, b);
  262. }
  263. }
  264. //=========================================================================================
  265. // [Distance Disable] Parameters access.
  266. //=========================================================================================
  267. /// <summary>
  268. /// アクティブ設定
  269. /// Active settings.
  270. /// </summary>
  271. public bool DistanceDisable_Active
  272. {
  273. get
  274. {
  275. return clothParams.UseDistanceDisable;
  276. }
  277. set
  278. {
  279. clothParams.UseDistanceDisable = value;
  280. }
  281. }
  282. /// <summary>
  283. /// 距離計測の対象設定
  284. /// nullを指定するとメインカメラが参照されます。
  285. /// Target setting for distance measurement.
  286. /// If null is specified, the main camera is referred.
  287. /// </summary>
  288. public Transform DistanceDisable_ReferenceObject
  289. {
  290. get
  291. {
  292. return clothParams.DisableReferenceObject;
  293. }
  294. set
  295. {
  296. clothParams.DisableReferenceObject = value;
  297. }
  298. }
  299. /// <summary>
  300. /// シミュレーションを無効化する距離
  301. /// Distance to disable simulation.
  302. /// </summary>
  303. public float DistanceDisable_Distance
  304. {
  305. get
  306. {
  307. return clothParams.DisableDistance;
  308. }
  309. set
  310. {
  311. clothParams.DisableDistance = Mathf.Max(value, 0.0f);
  312. }
  313. }
  314. /// <summary>
  315. /// シミュレーションを無効化するフェード距離
  316. /// DistanceDisable_DistanceからDistanceDisable_FadeDistanceの距離を引いた位置からフェードが開始します。
  317. /// Fade distance to disable simulation.
  318. /// Fade from DistanceDisable_Distance minus DistanceDisable_FadeDistance distance.
  319. /// </summary>
  320. public float DistanceDisable_FadeDistance
  321. {
  322. get
  323. {
  324. return clothParams.DisableFadeDistance;
  325. }
  326. set
  327. {
  328. clothParams.DisableFadeDistance = Mathf.Max(value, 0.0f);
  329. }
  330. }
  331. //=========================================================================================
  332. // [External Force] Parameter access.
  333. //=========================================================================================
  334. /// <summary>
  335. /// パーティクル重量の影響率(0.0-1.0).v1.12.0で廃止
  336. /// Particle weight effect rate (0.0-1.0).
  337. /// Abolished in v1.12.0.
  338. /// </summary>
  339. //public float ExternalForce_MassInfluence
  340. //{
  341. // get
  342. // {
  343. // return clothParams.MassInfluence;
  344. // }
  345. // set
  346. // {
  347. // clothParams.MassInfluence = value;
  348. // if (IsValid())
  349. // {
  350. // MagicaPhysicsManager.Instance.Team.SetExternalForce(TeamId, clothParams.MassInfluence, clothParams.WindInfluence, clothParams.WindRandomScale, clothParams.WindSynchronization);
  351. // }
  352. // }
  353. //}
  354. /// <summary>
  355. /// 深さによる外力の影響率(0.0-1.0)
  356. /// Impact of external force on depth.(0.0 - 1.0)
  357. /// </summary>
  358. /// <param name="startVal">0.0 ~ 1.0</param>
  359. /// <param name="endVal">0.0 ~ 1.0</param>
  360. /// <param name="curveVal">-1.0 ~ +1.0</param>
  361. public void ExternalForce_DepthInfluence(float startVal, float endVal, float curveVal = 0)
  362. {
  363. var b = clothParams.GetDepthInfluence().AutoSetup(startVal, endVal, curveVal);
  364. if (IsValid())
  365. {
  366. MagicaPhysicsManager.Instance.Team.SetDepthInfluence(TeamId, b);
  367. }
  368. }
  369. /// <summary>
  370. /// 風の影響率(1.0 = 100%)
  371. /// Wind influence rate (1.0 = 100%).
  372. /// </summary>
  373. public float ExternalForce_WindInfluence
  374. {
  375. get
  376. {
  377. return clothParams.WindInfluence;
  378. }
  379. set
  380. {
  381. clothParams.WindInfluence = value;
  382. if (IsValid())
  383. {
  384. MagicaPhysicsManager.Instance.Team.SetExternalForce(TeamId, clothParams.MassInfluence, clothParams.WindInfluence, clothParams.WindRandomScale, clothParams.WindSynchronization);
  385. }
  386. }
  387. }
  388. /// <summary>
  389. /// 風のランダム率(1.0 = 100%)
  390. /// Wind random rate (1.0 = 100%).
  391. /// </summary>
  392. public float ExternalForce_WindRandomScale
  393. {
  394. get
  395. {
  396. return clothParams.WindRandomScale;
  397. }
  398. set
  399. {
  400. clothParams.WindRandomScale = value;
  401. if (IsValid())
  402. {
  403. MagicaPhysicsManager.Instance.Team.SetExternalForce(TeamId, clothParams.MassInfluence, clothParams.WindInfluence, clothParams.WindRandomScale, clothParams.WindSynchronization);
  404. }
  405. }
  406. }
  407. //=========================================================================================
  408. // [World Influence] Parameter access.
  409. //=========================================================================================
  410. /// <summary>
  411. /// 移動影響の設定
  412. /// Setting up a moving influence.
  413. /// </summary>
  414. /// <param name="startVal">0.0 ~ 1.0</param>
  415. /// <param name="endVal">0.0 ~ 1.0</param>
  416. /// <param name="curveVal">-1.0 ~ +1.0</param>
  417. public void WorldInfluence_SetMovementInfluence(float startVal, float endVal, float curveVal = 0)
  418. {
  419. var b = clothParams.GetWorldMoveInfluence().AutoSetup(startVal, endVal, curveVal);
  420. if (IsValid())
  421. {
  422. MagicaPhysicsManager.Instance.Team.SetWorldInfluence(TeamId, clothParams.MaxMoveSpeed, clothParams.MaxRotationSpeed, b, clothParams.GetWorldRotationInfluence());
  423. }
  424. }
  425. /// <summary>
  426. /// 回転影響の設定
  427. /// Setting up a rotation influence.
  428. /// </summary>
  429. /// <param name="startVal">0.0 ~ 1.0</param>
  430. /// <param name="endVal">0.0 ~ 1.0</param>
  431. /// <param name="curveVal">-1.0 ~ +1.0</param>
  432. public void WorldInfluence_SetRotationInfluence(float startVal, float endVal, float curveVal = 0)
  433. {
  434. var b = clothParams.GetWorldRotationInfluence().AutoSetup(startVal, endVal, curveVal);
  435. if (IsValid())
  436. {
  437. MagicaPhysicsManager.Instance.Team.SetWorldInfluence(TeamId, clothParams.MaxMoveSpeed, clothParams.MaxRotationSpeed, clothParams.GetWorldMoveInfluence(), b);
  438. }
  439. }
  440. /// <summary>
  441. /// 最大速度の設定
  442. /// Setting up a max move speed.(m/s)
  443. /// </summary>
  444. public float WorldInfluence_MaxMoveSpeed
  445. {
  446. get
  447. {
  448. return clothParams.MaxMoveSpeed;
  449. }
  450. set
  451. {
  452. clothParams.MaxMoveSpeed = Mathf.Max(value, 0.0f);
  453. if (IsValid())
  454. {
  455. MagicaPhysicsManager.Instance.Team.SetWorldInfluence(TeamId, clothParams.MaxMoveSpeed, clothParams.MaxRotationSpeed, clothParams.GetWorldMoveInfluence(), clothParams.GetWorldRotationInfluence());
  456. }
  457. }
  458. }
  459. /// <summary>
  460. /// 自動テレポートの有効設定
  461. /// Enable automatic teleportation.
  462. /// </summary>
  463. public bool WorldInfluence_ResetAfterTeleport
  464. {
  465. get
  466. {
  467. return clothParams.UseResetTeleport;
  468. }
  469. set
  470. {
  471. clothParams.UseResetTeleport = value;
  472. if (IsValid())
  473. {
  474. MagicaPhysicsManager.Instance.Team.SetAfterTeleport(TeamId, clothParams.UseResetTeleport, clothParams.TeleportDistance, clothParams.TeleportRotation, clothParams.TeleportResetMode);
  475. }
  476. }
  477. }
  478. /// <summary>
  479. /// 自動テレポートと検出する1フレームの移動距離
  480. /// Travel distance in one frame to be judged as automatic teleport.
  481. /// </summary>
  482. public float WorldInfluence_TeleportDistance
  483. {
  484. get
  485. {
  486. return clothParams.TeleportDistance;
  487. }
  488. set
  489. {
  490. clothParams.TeleportDistance = value;
  491. if (IsValid())
  492. {
  493. MagicaPhysicsManager.Instance.Team.SetAfterTeleport(TeamId, clothParams.UseResetTeleport, clothParams.TeleportDistance, clothParams.TeleportRotation, clothParams.TeleportResetMode);
  494. }
  495. }
  496. }
  497. /// <summary>
  498. /// 自動テレポートと検出する1フレームの回転角度(0.0 ~ 360.0)
  499. /// Rotation angle of one frame to be judged as automatic teleport.(0.0 ~ 360.0)
  500. /// </summary>
  501. public float WorldInfluence_TeleportRotation
  502. {
  503. get
  504. {
  505. return clothParams.TeleportRotation;
  506. }
  507. set
  508. {
  509. clothParams.TeleportRotation = value;
  510. if (IsValid())
  511. {
  512. MagicaPhysicsManager.Instance.Team.SetAfterTeleport(TeamId, clothParams.UseResetTeleport, clothParams.TeleportDistance, clothParams.TeleportRotation, clothParams.TeleportResetMode);
  513. }
  514. }
  515. }
  516. /// <summary>
  517. /// テレポートのモードを設定
  518. /// Setting up a teleport mode.
  519. /// </summary>
  520. public ClothParams.TeleportMode WorldInfluence_TeleportMode
  521. {
  522. get
  523. {
  524. return clothParams.TeleportResetMode;
  525. }
  526. set
  527. {
  528. clothParams.TeleportResetMode = value;
  529. if (IsValid())
  530. {
  531. MagicaPhysicsManager.Instance.Team.SetAfterTeleport(TeamId, clothParams.UseResetTeleport, clothParams.TeleportDistance, clothParams.TeleportRotation, clothParams.TeleportResetMode);
  532. }
  533. }
  534. }
  535. /// <summary>
  536. /// リセット後の安定時間を設定(s)
  537. /// Set stabilization time after reset.
  538. /// </summary>
  539. public float WorldInfluence_StabilizationTime
  540. {
  541. get
  542. {
  543. return clothParams.ResetStabilizationTime;
  544. }
  545. set
  546. {
  547. clothParams.ResetStabilizationTime = Mathf.Max(value, 0.0f);
  548. if (IsValid())
  549. {
  550. MagicaPhysicsManager.Instance.Team.SetStabilizationTime(TeamId, clothParams.ResetStabilizationTime);
  551. }
  552. }
  553. }
  554. /// <summary>
  555. /// InfluenceTargetを置換する
  556. /// Replace InfluenceTarget.
  557. /// </summary>
  558. /// <param name="target"></param>
  559. public void WorldInfluence_ReplaceInfluenceTarget(Transform target)
  560. {
  561. bool active = status.IsActive;
  562. if (active)
  563. {
  564. Setup.ClothInactive(this);
  565. }
  566. // InfluenceTarget
  567. Params.SetInfluenceTarget(target);
  568. MagicaPhysicsManager.Instance.Team.ResetWorldInfluenceTarget(TeamId, target ? target : transform);
  569. if (active)
  570. {
  571. Setup.ClothActive(this, Params, ClothData);
  572. }
  573. }
  574. //=========================================================================================
  575. // [Collider Collision] Parameter access.
  576. //=========================================================================================
  577. /// <summary>
  578. /// アクティブ設定
  579. /// Active settings.
  580. /// </summary>
  581. public bool ColliderCollision_Active
  582. {
  583. get
  584. {
  585. return clothParams.UseCollision;
  586. }
  587. set
  588. {
  589. clothParams.SetCollision(value, clothParams.DynamicFriction, clothParams.StaticFriction);
  590. if (IsValid())
  591. {
  592. MagicaPhysicsManager.Instance.Compute.Collision.ChangeParam(TeamId, clothParams.UseCollision);
  593. }
  594. }
  595. }
  596. //=========================================================================================
  597. // [Penetration] Parameter access.
  598. //=========================================================================================
  599. /// <summary>
  600. /// アクティブ設定
  601. /// Active settings.
  602. /// </summary>
  603. public bool Penetration_Active
  604. {
  605. get
  606. {
  607. return clothParams.UsePenetration;
  608. }
  609. set
  610. {
  611. clothParams.UsePenetration = value;
  612. if (IsValid())
  613. {
  614. MagicaPhysicsManager.Instance.Compute.Penetration.ChangeParam(
  615. TeamId,
  616. clothParams.UsePenetration,
  617. clothParams.GetPenetrationDistance(),
  618. clothParams.GetPenetrationRadius(),
  619. clothParams.PenetrationMaxDepth
  620. );
  621. }
  622. }
  623. }
  624. /// <summary>
  625. /// 移動範囲球の設定
  626. /// Setting up a moving radius.
  627. /// </summary>
  628. /// <param name="startVal">0.0 ~ </param>
  629. /// <param name="endVal">0.0 ~ </param>
  630. /// <param name="curveVal">-1.0 ~ +1.0</param>
  631. public void Penetration_SetMovingRadius(float startVal, float endVal, float curveVal = 0)
  632. {
  633. clothParams.GetPenetrationRadius().AutoSetup(Mathf.Max(startVal, 0.0f), Mathf.Max(endVal, 0.0f), curveVal);
  634. if (IsValid())
  635. {
  636. MagicaPhysicsManager.Instance.Compute.Penetration.ChangeParam(
  637. TeamId,
  638. clothParams.UsePenetration,
  639. clothParams.GetPenetrationDistance(),
  640. clothParams.GetPenetrationRadius(),
  641. clothParams.PenetrationMaxDepth
  642. );
  643. }
  644. }
  645. }
  646. }