Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  ObiSolver.Lateupdate() bad performance
#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


Messages In This Thread
RE: ObiSolver.Lateupdate() bad performance - by TheMunk - 17-08-2021, 11:21 AM