Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] Magica Cloth

Discussion in 'Assets and Asset Store' started by hoshos, Jan 22, 2020.

  1. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    I tested it here and it didn't generate any errors.
    Also, there is no problem with your source code.
    First of all, at what timing is this AddCollider () called?

    Awake ()
    Start ()
    OnEnabled ()
    FixedUpdate ()
    Update ()
    LateUpdate ()
    .. Other

    Also, can you tell me the error message when (Jobs-> Burst-> Enable Compilation) is turned off from the menu as shown in the error message?
    (Don't forget to turn it back on later)
     
  2. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    Let me ask you a few questions about this issue.

    (1) What is a resource?
    Is a resource memory consumption or performance?
    As for memory, about 600 particles should not consume much.

    (2) Measurement location
    Could you please tell me where the data was aggregated?
    Is it a built app or a Unity Editor?
    What is the target for a build? (Android / iOS / PC ..)
     
  3. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    All MagicaCloth data is stored as sub-assets in the prefab as Scriptable Objects.
    At this time, unused sub-assets in the prefab are deleted at the same time.
    For this reason, it is a problem that old data remains like the image.

    First of all, I would like to know how to reproduce the situation like the image.
    Do you know the steps to reproduce the problem?
    Or it would be helpful if there was a reproducible project.

    Thank you.
     
  4. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    I understand the cause of the problem.
    This is probably incorrect usage.
    BlendWeight specifies the absolute value of the blend ratio between the original and the cloth simulation. (0.0 = 0%, 1.0 = 100%)
    Time.deltaTime is the processing time of each frame, so if it is 60fps, it will be a value like (0.0166, 0.017, 0.0165, 0.0163 ...).
    Therefore, substituting deltaTime for BlendWeight every frame causes vibration.
    For example, to set the blend ratio to 0%-> 100% in 1 second, specify as follows with Update ().

    boneCloth.UserBlendWeight = Mathf.Clamp01 (boneCloth.UserBlendWeight + 1.0f * Time.deltaTime);
     
  5. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    312
    It's called in Update().
    My character can change hair & costumes at runtime. I could just set the colliders to global but I wouldn't know the performance impact if there are multiple characters.

    The errors -
    Code (CSharp):
    1. ArgumentException: An item with the same key has already been added. Key: 1
    2. System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <9577ac7a62ef43179789031239ba8798>:0)
    3. System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <9577ac7a62ef43179789031239ba8798>:0)
    4. MagicaCloth.ParticleComponent.CreateParticle (System.UInt32 flag, System.Int32 teamId, System.Single depth, Unity.Mathematics.float3 radius, Unity.Mathematics.float3 localPos) (at Assets/MagicaCloth/Core/Physics/ParticleComponent/ParticleComponent.cs:276)
    5. MagicaCloth.MagicaCapsuleCollider.CreateColliderParticleReal (System.Int32 teamId) (at Assets/MagicaCloth/Core/Physics/ParticleComponent/MagicaCapsuleCollider.cs:155)
    6. MagicaCloth.ColliderComponent.CreateColliderParticle (System.Int32 teamId) (at Assets/MagicaCloth/Core/Physics/ParticleComponent/ColliderComponent.cs:121)
    7. MagicaCloth.BaseCloth.AddCollider (MagicaCloth.ColliderComponent collider) (at Assets/MagicaCloth/Core/API/BaseClothAPI.cs:106)
    8. DX.CharaManager.AssignHairToBody () (at Assets/_DX/Scripts/CharaManager.cs:266)
    9. DX.CharaManager.SpawnChara () (at Assets/_DX/Scripts/CharaManager.cs:168)
    10. DX.CharaManager.Start () (at Assets/_DX/Scripts/CharaManager.cs:53)
    Code (CSharp):
    1. IndexOutOfRangeException: Index -1 is out of range of '512' Length.
    2. Unity.Collections.NativeArray`1[T].FailOutOfRangeError (System.Int32 index) (at <e414e10bfe5f45729ff122f3359de21b>:0)
    3. Unity.Collections.NativeArray`1[T].CheckElementReadAccess (System.Int32 index) (at <e414e10bfe5f45729ff122f3359de21b>:0)
    4. Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at <e414e10bfe5f45729ff122f3359de21b>:0)
    5. MagicaCloth.PhysicsManagerParticleData+CopyBoneToParticleJob.Execute (System.Int32 index) (at Assets/MagicaCloth/Core/Physics/Manager/PhysicsManagerParticleData.cs:1030)
    6. Unity.Jobs.IJobParallelForExtensions+ParallelForJobStruct`1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <e414e10bfe5f45729ff122f3359de21b>:0)
     
  6. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Thank you for the detailed error.
    The situation has changed a little.
    Apparently I'm trying to register the same collider twice in the component.
    Do you have any idea?
     
  7. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    312
    I'm not sure myself, since I think my code should only get 1 item for each Bone Cloth and Capsule Collider. My code is only called once during the switching of chara hair.

    Code (CSharp):
    1. List<MagicaBoneCloth> magicaBone = new List<MagicaBoneCloth>();
    2. List<MagicaCapsuleCollider> magicaCollider = new List<MagicaCapsuleCollider>();
    3.  
    4. foreach (Transform item in charaBody.GetComponentsInChildren<Transform>())
    5. {
    6.     var magica = item.GetComponentInChildren<MagicaCapsuleCollider>();
    7.     magicaCollider.Add(magica);
    8. }
    9.  
    10. foreach (Transform item in charaHair.GetComponentsInChildren<Transform>())
    11. {
    12.     var magica = item.GetComponentInChildren<MagicaBoneCloth>();
    13.     magicaBone.Add(magica);
    14. }
    15.  
    16. foreach(var item in magicaBone)
    17. {
    18.     foreach(var col in magicaCollider)
    19.     {
    20.         item.AddCollider(col);
    21.     }
    22. }
     
  8. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    understood.
    I was able to roughly grasp it from the error message, so I will investigate it.
    Please give me some time.
     
    ikazrima likes this.
  9. tackor

    tackor

    Joined:
    Nov 24, 2017
    Posts:
    8
    So, will you add the function to support switch from MagicaCloth to Animation Control and Animation Control switch to MagicaCloth smooth in the future? I think it is important and necessary in some situation tha we can control cloth with animation or some other methods.
     
  10. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    What kind of support function would you like to have?
    I would appreciate it if you could tell me specifically.
    For example, it is possible to create something that automatically animates the blend rate at a specified time by executing the following API once.

    boneCloth.AnimationBlendWeight (weight: 0.0f, animationTime: 1.0f);

    Is it something like this?
     
  11. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    I've sent a fixed version to your [InBox].
    Could you please test if the error disappears with this version first?
     
    ikazrima likes this.
  12. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    13
    It's CPU performance.

    I measured it with the Unity profiler in Unity Editor. The project is intended for PC (and maybe PS4/PS5/XBox one/XBox Series).

    It is a very large 3D game, so our plan is to limit the CPU performance use of the code. Currently, Magica Cloth uses a significantly larger part of the CPU performance than any other script/system. I think that's weird since I trust Magica Cloth is light weight.
     
  13. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Thank you for the information.
    A multi-core PC should have a significant performance advantage.
    Can you first check if the Burst compiler is on?
    This can be confirmed from the menu as follows.
    Is this check unchecked?
    burst-1.jpg
     
  14. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    312
    Thanks!
     
  15. adamz

    adamz

    Joined:
    Jul 18, 2007
    Posts:
    1,060
    @hoshos

    Hey, just checking in to see how the cloth grab is coming along. Thanks.
     
  16. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    I'm sorry, work is delayed.
    Regarding the process of grabbing, I found a problem related to expansion and contraction during work and am currently looking for a solution.
    There are also many bug fixes that should be prioritized.
    Please wait for a while.
     
  17. tackor

    tackor

    Joined:
    Nov 24, 2017
    Posts:
    8
    That's better. If possible
     
  18. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    understood.
    We'll add this API to our future roadmap.
    However, this feature is not urgent and is a lower priority.
    I would like to implement it when I have time to spare.
     
  19. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Update: 1.9.2

    v1.9.2 has been released on the Asset Store!
    http://u3d.as/1Hzx

    This time, the friction calculation was reviewed and static friction was introduced.
    This will improve the phenomenon of particles slipping over the collider.
    The left side of the video is the conventional one, and the right side is the one with static friction enabled.


    Friction is specified on the Collider Collision panel.
    If you want to apply strong friction like a movie, try setting it to about the value of the image.
    (The initial value is a little weaker)
    staticfriction-1.jpg

    Release Note:
    Added: Added static friction. You can improve the problem of particles slipping on the collider.
    Improvement: Improved friction calculation.
    Improvement: Adjusted the initial value of each component
    Improvement: Adjusted each preset
    Fix: Fixed an issue where fixed particles were misaligned with the previous frame. Vibration during movement is improved.
    Fix: Fixed an issue where MeshCloth polygons would disappear in rare situations.

    https://magicasoft.jp/en/release-note-2/
     
    PutridEx likes this.
  20. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    13
    Hi,
    It is checked, also we'd like the game to be able to work on dual core CPUs (to the best it can).
     
  21. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    I am worried that the performance is poor when Burst is ON.
    Sorry to trouble you, but is it possible to get profiler information?
    Profiler information can be saved like an image.
    profiler-1.jpg

    If possible, could you please tell me the save file, the version of Unity you are using, and the type of CPU?
     
    Last edited: Feb 28, 2021
  22. Quang_Phan

    Quang_Phan

    Joined:
    Dec 28, 2016
    Posts:
    13
    Hello Magica Soft,
    I just import new version of Magica Cloth 1.9.2 then I following your tutorial setup project in Unity 2019.4.9f1. When I installed install Jobs, Math.... following https://magicasoft.jp/en/magica-cloth-install-2/ it get a lot of errors then I removed all and install Jobs preview 13. 0.2.10 it remove almost errors but still has this error and I can't fix it:
    Assets\MagicaCloth\Scripts\Core\Physics\Manager\PhysicsManagerCompute.cs(877,38): error CS0117: 'math' does not contain a definition for 'project'
    Please let me know how can I fix it, thank you
     

    Attached Files:

  23. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello
    I'm very sorry, this is my mistake.
    The mathematics function (math.project ()) used in v1.9.2 does not seem to exist in mathematics version 1.1.0.
    This function is available from v1.2.1 of mathematics, so sorry to trouble you, but could you install 1.2.1 as shown in the image?
    The preview package is displayed by selecting Show Preview Package as shown in the image.
    We will fix this issue immediately and update the assets.
    showpreview.jpg math121.jpg
     
  24. Quang_Phan

    Quang_Phan

    Joined:
    Dec 28, 2016
    Posts:
    13
    Thank you for quick response, I will try it !
     
  25. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Update: 1.9.3

    v1.9.3 has been released on the Asset Store!
    http://u3d.as/1Hzx

    This is an urgent update.
    Fixed an issue that caused a compile error when the Mathematics package was 1.1.0.

    Release Note:
    Improvement: The initial value of static friction was too strong, so it was reduced to 0.03.
    Fix: Fixed an issue that caused an error in the Mathematics 1.1.0 package.
    Fix: Fixed an issue where deferred execution future prediction was not working properly.
    Fix: Fixed an issue that caused an error when registering the same collider twice with AddCollider ().
    Fix: BlendWeight is internally clamped to 0-1.

    https://magicasoft.jp/en/release-note-2/
     
    Acissathar likes this.
  26. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    412
    Hi,

    Firstly, thank you for the help last time. I now have animations for my wings and am trying to use MagicaCloth to make the feathers have physics, based on the settings and setup you gave me last time.

    MagicaCloth turned off:
    upload_2021-3-8_12-0-33.png

    As you can see, the feathers don't follow physics here. They should hang down instead of pointed inward.

    MagicaCloth turned on:
    upload_2021-3-8_12-1-9.png

    As you can see, now the wing bones are not hanging down. How do I reduce MagicaCloth's influence on the animated bones? I only want to animate the feathers.
     
  27. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    It is possible to change the influence rate with Blend Weight from the original animation.
    This value can be changed at runtime.
    This feature may be useful.
    blendweight-1.jpg

    https://magicasoft.jp/en/basecloth-2/
    public float BlendWeight;
     
    Exeneva likes this.
  28. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    13
    Hi,
    We can't compile our game, Unity seems to be trying to compile the scripts within the Editor folders in the MagicaCloth folder.
     
  29. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    Probably because it supports Unity Assembly Definition (asmdef) from v1.9.0.
    Sorry to trouble you, but please delete the folder of MagicaCloth once and import the latest version.
     
  30. yao20201209

    yao20201209

    Joined:
    Mar 3, 2021
    Posts:
    1
    Hello, how do MagicaCloth deal with the very close simulation of the double-sided fold of the model. For example, I need a double-folded model. The upper layer shows the tulle, and the bottom shows the normal fabric. Is there any way to prevent the double-sided fabric?
     
  31. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    Perhaps you want to simulate on a vertex-by-vertex basis for a mesh that does not contain bones.
    If the front and back meshes are separated into two, there is a function to combine the two meshes into one virtual mesh.
    By using this, multiple meshes can be regarded as one mesh and cloth simulation is possible.
    Please refer to the following document for this function.

    https://magicasoft.jp/en/magicaclothmeshclothstart-2/
     
  32. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    13
    It worked! Thanks a lot!
     
  33. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    13
    Hi,
    I recorded the profiler datas you requested on Unity 2020.3 LTS with an Intel I7 10700k (8c/16t). Unfortunately, the file is 183Mo and 13Mo when compressed so I cannot send it on the forum.
    Anyway, here is a screenshot of the profiler. Magica uses all 16 threads but the whole process is taking 0.5ms (on this high-end cpu).

    upload_2021-3-16_16-24-16.png

    upload_2021-3-16_16-16-7.png
     
  34. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Thank you for the profile image.
    As far as you can see this profile, the operation is normal.
    First of all, running in the Unity editor looks worse than it really is because it includes profile collection and safechecks.
    Therefore, pay attention to the performance of 2 to 3 times by actually building.

    If performance is still an issue, you can also use a delayed execution mode.
    https://magicasoft.jp/en/magica-cloth-physics-manager-2/
    This mode allows you to run the simulation while rendering, which greatly improves performance.
    However, be careful because the result is delayed by one frame.
    This delay is automatically interpolated by predicting the future.

    There is still plenty of room for optimization in terms of performance, and I plan to do that later this year.
     
  35. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Update: 1.9.4

    v1.9.4 has been released on the Asset Store!
    http://u3d.as/1Hzx

    Improved the vibration problem related to static friction added from v1.9.2.
    It also fixes various issues that occurred in Unity Physics (Fixed Update) mode.

    Release Note:
    Improvement: The problem of vibration caused by static friction has been improved.
    Fix: Fixed various issues that were occurring in Unity Physics mode.
    Fix: From v1.9.2, fixed the problem that the collision particles were vibrating strongly depending on the situation.

    https://magicasoft.jp/en/release-note-2/
     
  36. Shii

    Shii

    Joined:
    Nov 23, 2014
    Posts:
    16
    Since I started using Magica Cloth my Unity Editor (2019.4.21f1) started crashing sometimes. Crashes usually happens when scripts recompiling and happening almost every day since last summer when I bought Magica Cloth. Apparently it caused by one of the packages required by Magica Cloth, probably preview Jobs or Collections. Is it a known issue and is there any recommended stable version of these packages that I should use?
    Currently using:
    Burst 1.4.6
    Collections 0.9.0-preview.6
    Jobs 0.2.10-preview.13
    Mathematics 1.2.1
     
    Last edited: Mar 17, 2021
  37. Mentalist_

    Mentalist_

    Joined:
    Apr 28, 2019
    Posts:
    3
    Hello,
    I'm using Magica, to record the motions of the cloths. What I currently have records the moving vertices per frame (the one I set from the point selection) in MagicaMeshCloth. I get the list of the indices in the vertices array being used by
    MagicaMeshCloth.GetSelectionList();
    and then only storing the vertices mapped to those indices.

    But, if, I use MergeVertexDistance or MergeTriangleDistance, the vertexCount returned by MagicaMeshCloth.GetSelectionList() gets reduced, and I cannot map the returned indices directly to the vertex array I get from the mesh. Can you highlight on how I could get the reduced vertex and triangle list that I can store and then use that to play again?

    Here's essentially what I'm doing. (Sorta pseudo code in the end)
    Code (CSharp):
    1. public class Testing : MonoBehaviour
    2.     {
    3.         public SkinnedMeshRenderer renderer;
    4.         public MagicaMeshCloth cloth;
    5.      
    6.         private List<int> movingIndices;
    7.         private bool recording;
    8.         private void OnValidate()
    9.         {
    10.             List<int> selList = cloth.GetSelectionList();
    11.             for (int i = 0; i < selList.Count; i++)
    12.             {
    13.                 if(selList[i]==1)
    14.                     movingIndices.Add(i);
    15.             }
    16.         }
    17.      
    18.         private void Start()
    19.         {
    20.             Mesh mesh = new Mesh();
    21.             renderer.BakeMesh(mesh);
    22.             var triangles = mesh.triangles;
    23.             //store triangles.
    24.             recording = true;
    25.         }
    26.  
    27.         private void Update()
    28.         {
    29.             if (recording)
    30.             {
    31.                 for (int i = 0; i < movingIndices.Count; i++)
    32.                 {
    33.                     Mesh mesh = new Mesh();
    34.                     renderer.BakeMesh(mesh);
    35.  
    36.                     foreach (var movingIndex in movingIndices)
    37.                     {
    38.                         Vector3 t = mesh.vertices[movingIndex];
    39.                         //store t.
    40.                     }
    41.                 }
    42.             }
    43.         }
    44.  
    45.         private void PlayBack()
    46.         {
    47.                  //per frame, form the vertices array from memory and do
    48.                  Mesh mesh = new Mesh {recFrameVertices, recTriangles}
    49.                  renderer.sharedMesh = mesh;
    50.         }
    51.     }
    But this doesn't work, if the merge vertex/triangle distance, this wouldn't work. Would it be possible to get the reduced mesh vertices and triangles?

    I also tried,
    MagicaMeshCloth.GetMeshData()
    (after making the accessor public), but although it returns the correct updated vertex count, it still gives me no way to map the indices to the original vertices array.
     
    Last edited: Mar 17, 2021
  38. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    I have encountered this problem several times.
    Unfortunately, the cause is still unknown.
    However, it is a problem only for the editor, and it seems that a crash will not occur in the build.

    No stable version has been confirmed for the package.
    Be sure to always install the latest version.
    Also, upgrading to Unity 2020 may solve the problem if possible.
    This is because the package versions are different in Unity 2018, 2019, 2020.
    The package version in Unity2020.3.LTS is as follows.

    <Unity2020.3.LTS>
    Burst 1.4.6
    Collections 0.15.0-preview21
    Jobs 0.8.0-preview23
    Mathematics 1.2.1
     
  39. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    This is a difficult process.
    First, MeshCloth works with virtual meshes with Virtual Deformer.
    Virtual Deformer combines multiple meshes to reduce vertices and create a virtual mesh.
    Therefore, there is no one-to-one correspondence between the selected data list of MeshCloth and the vertices of the mesh of Renderer.
    Therefore, you need to separate the Virtual Deformer vertices into the corresponding Renderer vertex indexes.
    Unfortunately there is currently no function to do this.
    So I created a pseudo code to do this.
    The following GetSelectionMeshVertexList () corresponds to that.
    For meshIndex, give the index of RenderDeformer set in VirtualDeformer.
    You should now be able to get the list of vertices for the mesh set to Move and Fixed in Vertex Paint.
    Also note that this function is slow because it is not intended to run in line time.

    <MagicaMeshClolth.cs>
    Code (CSharp):
    1.  
    2.         public List<int> GetSelectionMeshVertexList(int meshIndex)
    3.         {
    4.             var vlist = new List<int>();
    5.  
    6.             // Selection data.
    7.             var selData = GetSelectionList();
    8.  
    9.             // All RenderDeformer vertices referenced by VirtualDeformer
    10.             Dictionary<int, List<uint>> dict = Deformer.MeshData.GetVirtualToChildVertexDict();
    11.  
    12.             foreach (var kv in dict)
    13.             {
    14.                 int virtualDeformerIndex = kv.Key;
    15.  
    16.                 // Select data judgment
    17.                 var sel = selData[virtualDeformerIndex];
    18.                 if (sel != SelectionData.Move && sel != SelectionData.Fixed)
    19.                     continue;
    20.  
    21.                 foreach (var pack in kv.Value)
    22.                 {
    23.                     int cmindex = DataUtility.Unpack16Hi(pack);
    24.                     int cvindex = DataUtility.Unpack16Low(pack);
    25.  
    26.                     // render deformer judgment
    27.                     if (cmindex != meshIndex)
    28.                         continue;
    29.  
    30.                     vlist.Add(cvindex);
    31.                 }
    32.             }
    33.  
    34.             return vlist;
    35.         }
    36.  
     
    Mentalist_ likes this.
  40. Mentalist_

    Mentalist_

    Joined:
    Apr 28, 2019
    Posts:
    3
    Firstly, thanks a ton for replying, and for the piece of code you provided.
    I tried it out and ran into a problem. Although its returning the correct length of vertices array, its returning values (I presume they are indices), but I cannot figure out how the function you provided to calculate whether the vertex is moving or not.
    The function returns something like this upload_2021-3-19_14-42-31.png

    But I expected in it to be a 0 or 1 value, depending on whether it was a moving vertex or a fixed vertex. The code I used is pretty simple :

    Code (CSharp):
    1.  
    2. List<int> temp = cloth.GetSelectionMeshVertexList(0); //methodprovided
    3. Debug.Log($"selectionMeshVertexList.Count = {temp.Count}"); //returns the correct count
    4. for (int i = 0; i < temp.Count; i++)
    5. {
    6.      Debug.Log($"selectionMeshVertexList[{i}]={temp[i]}");
    7.  
    8. }
    Can you highlight on how I could achieve this? Thank you :)
     
  41. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    In this case, the content of the list will be the vertex index of the mesh marked with Move / Fixed.
    So in the image example, the vertex indexes 0,1,65,539,540,541,550,949,950,2 are marked with Move or Fixed.
     
    Mentalist_ likes this.
  42. Mentalist_

    Mentalist_

    Joined:
    Apr 28, 2019
    Posts:
    3
    Thank you for replying!
    I actually wanted to classify the vertex indices on whether they were moving or fixed. Tweaked your original code a bit, and voila!

    Code (CSharp):
    1.  
    2. public (List<int>, List<int>) GetSelectionMeshVertexList(int meshIndex)
    3.         {
    4.             List<int> vMoveList = new List<int>();
    5.             List<int> vFixedList = new List<int>();
    6.  
    7.             // Selection data.
    8.             List<int> selData = GetSelectionList(); //reduced vertices only.
    9.  
    10.             // All RenderDeformer vertices referenced by VirtualDeformer
    11.             Dictionary<int, List<uint>> dict = Deformer.MeshData.GetVirtualToChildVertexDict();
    12.  
    13.             foreach (KeyValuePair<int, List<uint>> kv in dict)
    14.             {
    15.                 int virtualDeformerIndex = kv.Key;
    16.  
    17.                 int sel = selData[virtualDeformerIndex];
    18.  
    19.                 if (sel == SelectionData.Move)
    20.                 {
    21.                     foreach (uint pack in kv.Value)
    22.                     {
    23.                         int cmindex = DataUtility.Unpack16Hi(pack);
    24.                         int cvindex = DataUtility.Unpack16Low(pack);
    25.  
    26.                         // render deformer judgment
    27.                         if (cmindex != meshIndex)
    28.                             continue;
    29.  
    30.                         vMoveList.Add(cvindex);
    31.                     }
    32.                 }
    33.                 else if (sel == SelectionData.Fixed)
    34.                 {
    35.                     foreach (uint pack in kv.Value)
    36.                     {
    37.                         int cmindex = DataUtility.Unpack16Hi(pack);
    38.                         int cvindex = DataUtility.Unpack16Low(pack);
    39.  
    40.                         // render deformer judgment
    41.                         if (cmindex != meshIndex)
    42.                             continue;
    43.  
    44.                         vFixedList.Add(cvindex);
    45.                     }
    46.                 }
    47.             }
    48.  
    49.             return (vMoveList, vFixedList);
    50.         }
    Again, thanks a lot!
     
    hoshos likes this.
  43. Ologon

    Ologon

    Joined:
    Nov 16, 2014
    Posts:
    13
    Hello, I have a question regarding magica cloth. Is it possible to mix it with unity’s animation rigging package? (Have some bones controlled by animation rigging constraints and some bones by magica cloth. I might also need to attach magica cloth colliders to bones controlled by animation rigging’s IK constraints)
     
    Last edited: Mar 25, 2021
  44. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    I haven't confirmed Unity's Animation Rigging, but I think it will work.
    There is no problem with a similar Final IK.
    If you are uncertain, please let us know as we will give you an evaluation version.
     
  45. Ologon

    Ologon

    Joined:
    Nov 16, 2014
    Posts:
    13
    I see, thank you! An evaluation version would be very helpful to help me test it. I sent an email through the website contact form. :)
     
    Last edited: Mar 25, 2021
  46. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    I replied to the email so please test it.
    If you like it, I would be grateful if you could purchase it.
     
    Ologon likes this.
  47. athert

    athert

    Joined:
    Dec 31, 2012
    Posts:
    24
    Helloo. Im not sure if someone asked already but will there be (or is already there) option to manage collision between multiple clothing objects? I have clothing that can overlap with different piece of clothing and there is physic (magica) running on both of them. They can sometimes intersect each other and its not looking good.
    If its not done yet, can you tell me if its planned and when it should be released? :D
     
  48. Ologon

    Ologon

    Joined:
    Nov 16, 2014
    Posts:
    13
    Tested and purchased it! It worked without problems with Unity's animation rigging :)
     
  49. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Hello.
    Sorry, there is currently no proper way to handle layer cloth collisions.
    Currently, there is no choice but to avoid it with colliders of different sizes.
    The collision detection of layer cloth is the number one goal of this year, including self-collision.
    For this reason, we are still experimenting, and hopefully it will be resolved later this year.
     
    ObiOneStenobi and athert like this.
  50. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    361
    Thank you for purchasing!
    I'm also happy that it worked with Unity Animation Rigging.
     
    Ologon likes this.
unityunity