Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  ObiSolver.Lateupdate() bad performance
#21
(16-08-2021, 10:15 AM)TheMunk Wrote: Yea like a lasso

You could use two ropes, or abuse the fact that self-collisions will ignore pairs of particles that intersect at rest. This prevents particles that overlap (such as when you have high-resolution ropes) from colliding with each other and causing a mess.

The rest position of particles is stored in the restPositions array in the solver. For ropes, these are initialized assuming the rope is completely straight. If for some reason you wanted specific particles in a rope to ignore self-collisions with each other, you could programmatically set their rest positions so that certain particles overlap.

From the manual:

http://obi.virtualmethodstudio.com/manua...icles.html

Quote:Rest position: Rest position of the particles in the actor. These are used to ignore self-particle collisions between particles that were already intersecting in the actor's rest configuration.
Reply
#22
(16-08-2021, 10:22 AM)josemendez Wrote: You could use two ropes, or abuse the fact that self-collisions will ignore pairs of particles that intersect at rest. This prevents particles that overlap (such as when you have high-resolution ropes) from colliding with each other and causing a mess.

The rest position of particles is stored in the restPositions array in the solver. For ropes, these are initialized assuming the rope is completely straight. If for some reason you wanted specific particles in a rope to ignore self-collisions with each other, you could programmatically set their rest positions so that certain particles overlap.

From the manual:

http://obi.virtualmethodstudio.com/manua...icles.html
Ah I see, just stitching the particles in the blueprint when they are exactly on top of each other fixes this.
Thanks!
Reply
#23
(16-08-2021, 10:22 AM)josemendez Wrote: You could use two ropes, or abuse the fact that self-collisions will ignore pairs of particles that intersect at rest. This prevents particles that overlap (such as when you have high-resolution ropes) from colliding with each other and causing a mess.

The rest position of particles is stored in the restPositions array in the solver. For ropes, these are initialized assuming the rope is completely straight. If for some reason you wanted specific particles in a rope to ignore self-collisions with each other, you could programmatically set their rest positions so that certain particles overlap.

New issue; when extending the rope/lasso length from the beginning the restPositions hack breaks and collision starts happening again.

I tried with the two-rope solution, but stitching together the loop and the rope so that bending constraints remain makes the physics go wonky. 

Tried stitching like this;

   

          (o)--------(o)---------(o)--------(o)---------(o)
           !          !                                  |
(o)-------(o)--------(o)          This is the loop rope  |
           !          !                                  |
          (o)--------(o)---------(o)--------(o)---------(o)


where it's a stitched loop (not an actual loop made in the blueprint edit mode).

Edit: Looks like I need some way of constantly disabling self-collision for a specific particle to fix this.
Reply
#24
(16-08-2021, 03:19 PM)TheMunk Wrote: New issue; when extending the rope/lasso length from the beginning the restPositions[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif] hack breaks and collision starts happening again.

You need to set custom restPositions every frame, since using a cursor the extend/retract the rope re-calculates all restPositions.

(16-08-2021, 03:19 PM)TheMunk Wrote: Edit: Looks like I need some way of constantly disabling self-collision for a specific particle to fix this.

The only way to do this is trough settings restPositions. Filters don't work for self-collisions.
Reply
#25
(17-08-2021, 09:08 AM)josemendez Wrote: You need to set custom restPositions every frame, since using a cursor the extend/retract the rope re-calculates all restPositions.
Ahh, I see. Figured it out. Here's a generic solution for anyone who wants the same behavior;

Code:
using Obi;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;

public class ObiStitchSelfCollisionDisabler : MonoBehaviour
{
    public bool DisableSelfCollisionOnStitchedParticles = true;

    [SerializeField]
    private ObiStitcher ObiStitcher;

    private List<ObiStitcher.Stitch> stitches;

    private void Start()
    {
        stitches = ObiStitcher.Stitches.ToList();
    }

    private void FixedUpdate()
    {
        foreach (ObiStitcher.Stitch stitch in stitches)
        {
            if (DisableSelfCollisionOnStitchedParticles)
            {
                ObiStitcher.Actor1.solver.restPositions[stitch.particleIndex1] = new Vector3(0, 0, 0);
                ObiStitcher.Actor2.solver.restPositions[stitch.particleIndex2] = new Vector3(0, 0, 0);
            }
        }

       
    }
}
Be aware I didn't test this with two different actors - I'm just assuming actor1 matches particleIndex1.

Thanks a lot Josemendez!
Reply