Search Forums

(Advanced Search)

Latest Threads
How to dynamically change...
Forum: Obi Rope
Last Post: josemendez
7 hours ago
» Replies: 5
» Views: 132
Pipeline that bends
Forum: Obi Softbody
Last Post: josemendez
04-07-2025, 09:52 AM
» Replies: 13
» Views: 817
How to implement/sync Obi...
Forum: Obi Rope
Last Post: quent_1982
01-07-2025, 01:48 PM
» Replies: 2
» Views: 195
Collisions don't work con...
Forum: Obi Rope
Last Post: chenji
27-06-2025, 03:05 AM
» Replies: 3
» Views: 259
Force Zone apply differen...
Forum: Obi Rope
Last Post: chenji
26-06-2025, 11:41 AM
» Replies: 11
» Views: 768
Can I blend in and out of...
Forum: Obi Cloth
Last Post: josemendez
24-06-2025, 04:42 PM
» Replies: 3
» Views: 244
Using a rigidbody/collide...
Forum: Obi Cloth
Last Post: josemendez
24-06-2025, 09:29 AM
» Replies: 1
» Views: 149
Solver is too performance...
Forum: Obi Rope
Last Post: quent_1982
20-06-2025, 08:09 AM
» Replies: 40
» Views: 4,263
Obi 7 Model Scaling
Forum: Obi Cloth
Last Post: alkis
19-06-2025, 02:37 PM
» Replies: 2
» Views: 259
Obi Softbody instability?
Forum: Obi Softbody
Last Post: Aroosh
18-06-2025, 06:35 PM
» Replies: 0
» Views: 138

 
  Particle collision with soft body
Posted by: Duncano - 02-05-2025, 10:49 AM - Forum: Obi Softbody - Replies (2)

Is there a way to enable interactions with a unity particle system and Obi Soft body?...i suspect not

I seem to suspect it shoudl be possible with an OBI partilce system....but i cant seem to find out how to create an Obi Particle emitter... ( i have Obi soft body and Cloth)

essentially i want to simulate a  ( bio science) cell being targetted by a swarm of rigid body spheres.


any advice much appreciated

thanks,
DUncan

Print this item

  Memory leak warning with GPU compute solver
Posted by: Softscale - 02-05-2025, 02:25 AM - Forum: Obi Fluid - Replies (4)

(Unity 2022.3.61f1, Obi 7.0.5, Windows 10)



Hey there, I've recently been updating my project from Obi 6 to 7, and also switching to use the GPU compute solver. I noticed in the editor after some testing and re-starting play mode, it would pop up 12 warnings with this:

Code:
GarbageCollector disposing of GraphicsBuffer. Please use GraphicsBuffer.Release() or .Dispose() to manually release the buffer.


This wasn't a major issue, however I also started to get crashes on the built version of my game when exiting, with the stack trace in the Player.log ending with:

Code:
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFC2836FDFB)
0x00007FFC2836FDFB (UnityPlayer) (function-name not available)
  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFC27DB3BAE)
0x00007FFC27DB3BAE (UnityPlayer) (function-name not available)
0x00000293A7D6D9DA (Mono JIT Code) (wrapper managed-to-native) UnityEngine.GraphicsBuffer:DestroyBuffer (UnityEngine.GraphicsBuffer)
0x00000293A7D6D8B3 (Mono JIT Code) UnityEngine.GraphicsBuffer:Dispose (bool)
0x00000293A7D6D823 (Mono JIT Code) UnityEngine.GraphicsBuffer:Dispose ()
0x00000293A6AE4D53 (Mono JIT Code) Obi.ObiNativeList`1<Obi.TriangleMeshHeader>:DisposeOfComputeBuffer ()
0x0000029665B30A63 (Mono JIT Code) Obi.ObiNativeList`1<Obi.TriangleMeshHeader>:Dispose (bool)
0x0000029665B309AB (Mono JIT Code) Obi.ObiNativeList`1<Obi.TriangleMeshHeader>:Finalize ()
0x000002937187A18C (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr)
0x00007FFC2B156F77 (mono-2.0-bdwgc) mono_callspec_cleanup
0x00007FFC2B158118 (mono-2.0-bdwgc) mono_gc_finalize_notify
0x00007FFC2B158680 (mono-2.0-bdwgc) mono_gc_finalize_notify
0x00007FFC2B0EF9AB (mono-2.0-bdwgc) mono_profiler_init_etw
0x00007FFC2B0EFBBE (mono-2.0-bdwgc) mono_profiler_init_etw
0x00007FFD51F47374 (KERNEL32) BaseThreadInitThunk
0x00007FFD521BCC91 (ntdll) RtlUserThreadStart


Doing a build with the Development Build flag did not crash on exit but also threw those GarbageCollector warnings.



After some tracing, all of the warnings were coming from ComputeColliderWorld.cs. I added Dispose()s for each of the buffers that were causing problems to the OnDestroy:


Code:
transformsBuffer?.Dispose();
aabbsBuffer?.Dispose();
materialsBuffer?.Dispose();
shapesBuffer?.Dispose();
forceZonesBuffer?.Dispose();
rigidbodiesBuffer?.Dispose();
distanceFieldHeaders?.Dispose();
bihNodes?.Dispose();
triangleMeshHeaders?.Dispose();
dfNodes?.Dispose();
triangles?.Dispose();
vertices?.Dispose();

This fixed the warnings popping up in editor, and the game no longer crashes on exit in the built version. There may be other buffers that also need to be disposed in this component but these were the ones that were causing issues for my game. Just wanted to let you know about this problem.

Print this item

Pregunta Rope cursor with attachments
Posted by: Balou - 01-05-2025, 03:09 PM - Forum: Obi Rope - Replies (1)

Hi,
Using Obi 6.3. 
Here is my setup:
3--2-----1

1,2,3 are attachment on the rope.
I'm trying to extend or rewind the rope at these two position
3--2>-----<1 where > < can be < > (cursor direction), meaning rope can extend from the two points or rewind from the two.
It works fine with the one next to 1 (the start of the rope, cursor is at 0, source at .5
But if I try to place the cursor next to the 2, something like cursor at .3 and source still at .5 it behave differently, no particle are added to the rope at this position.

Is there something I should know about cursor and attachments?
Edit: IF I understand correctly one of the issue is, when the cursor is at .75 and the rope is getting bigger, the cursor move, so I need to find a way to dynamically set it to one particle...
Thanks a lot,

Print this item

Triste Issue Saving/Loading Particle Positions in play mode using ObiRope v7.0
Posted by: ozeecode - 28-04-2025, 12:31 PM - Forum: Obi Rope - Replies (10)

Hello,
I managed to save and reload particle positions in ObiRope v6.x using code under the Copy ropes in play mode thread. However, this no longer works in ObiRope v7.x. Could you help me identify what I might be missing?

Here’s my current code:


Code:
public void Load(Vector3[] particlePositions, Vector3 lastParticlePosition)
{
    int particleCount = particlePositions.Length;
    while (rope.activeParticleCount > particleCount)
    {
        rope.elements.RemoveAt(rope.elements.Count - 1);
        rope.DeactivateParticle(rope.activeParticleCount - 1);
    }

    while (rope.activeParticleCount < particleCount)
    {
        rope.elements.Add(new ObiStructuralElement
        {
            particle1 = rope.elements[^1].particle1,
            //maybe this should be so:
            //particle2 = rope.elements[^1].particle2,
            particle2 = rope.solverIndices[rope.activeParticleCount],
            restLength = rope.interParticleDistance
        });
        rope.CopyParticle(rope.activeParticleCount - 1, rope.activeParticleCount);
        rope.ActivateParticle(); // This doesn't have an actorIndex anymore.
    }


    for (int j = 0; j < rope.elements.Count; ++j)
    {
        int firstParticle = rope.elements[j].particle1;
        rope.solver.positions[firstParticle] = particlePositions[j];
        rope.solver.velocities[firstParticle] = Vector4.zero;
        rope.solver.angularVelocities[firstParticle] = Vector4.zero;
    }

    int lastParticle = rope.elements[^1].particle2;
    rope.solver.positions[lastParticle] = lastParticlePosition;
    rope.solver.velocities[lastParticle] = Vector4.zero;
    rope.solver.angularVelocities[lastParticle] = Vector4.zero;
    rope.RebuildConstraintsFromElements();
}

The save sections look like this:
Code:
int positionCount = rope.elements.Count;
Vector3[] particlePositions = new Vector3[positionCount];
for (int j = 0; j < positionCount; ++j)
{
    particlePositions[j] = rope.solver.positions[rope.elements[j].particle1];
}

Vector3 lastParticlePosition = rope.solver.positions[rope.elements[positionCount - 1].particle2];



Thanks!

Print this item

  Attachments Not Working - Disable/Renable?
Posted by: scoull - 27-04-2025, 09:44 PM - Forum: General - Replies (2)

Hi All, thanks in advance for taking a look.

I am working with attachments for the first time using Obi Fluid. I am able to create the attachment with a proper target and particle group, but when adding particles to the particle group, nothing happens.

Additionally, if I try to disable/reenable the attachment at runtime (which I don't even think is necessary if I'm just adding/removing particles), then unity crashes and gives the GPU error "Failed to present D3D11 swapchain due to device reset/removed". I am using compute backend.


Code:
    void Solver_OnCollision (ObiSolver solver, ObiNativeContactList contacts){
        for(int i = 0;  i < contacts.count ; ++i)
        {
            //Get properies of the particle in the contact
            int particleIndex = solver.simplices[contacts[i].bodyA];
            ObiSolver.ParticleInActor pa = solver.particleToActor[particleIndex];
            ObiParticleAttachment attachment = pa.actor.gameObject.GetComponent<ObiParticleAttachment>();
            ObiParticleGroup group = attachment.particleGroup;

            //Changing the collision index of the particle so that it won't collide anymore
            //In preparation for attaching to object
            solver.filters[particleIndex]=ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, (1 << 1));

            //Add particle to attachment group between emitter and object
            if(!group.ContainsParticle(pa.indexInActor)){
                group.particleIndices.Add(pa.indexInActor);
                attachment.particleGroup=group;
                Debug.Log("Attachments count " + attachment.particleGroup.Count);
            }
        }
    }

Print this item

  Aerodynamics for non cloth
Posted by: Jawsarn - 24-04-2025, 08:41 PM - Forum: General - Replies (10)

Do I understand correctly from documentation that only cloth has simulation of aerodynamics from particle velocity?
Is there a way to enable this, or do I need to do this by code or apply fake "wind" each tick? E.g. apply aerodynamics on bones for ears when moving a character.

Print this item

  Obi Bone FixedRoot As Parent
Posted by: Jawsarn - 23-04-2025, 11:03 PM - Forum: Obi Rope - Replies (8)

Is it possible to have the root bone be part of the chain as if there was a parent transform with same position and rotation with "Fix Root" enabled?

I feel this should be a opt in to have the root bone be driven by animation or fully simualted. It is not great for workflow to have to modify existing rigs to enable this behaviour.

Print this item

  Obi 7 Questions
Posted by: MEPETAMINALS - 20-04-2025, 06:56 PM - Forum: Obi Cloth - Replies (5)

Hi, I've been heavily using Obi (cloth and rope) for several years now in the development of Following Seas. I'm quite happy with it overall, with really the biggest issue coming down to performance. Typically about 30-50% of total profiler load goes into the system -- which has been acceptable, but definitely reduces the number of runnable systems for users.

I've been looking into Obi 7, as performance seems to be a major focus, and have also split into a separate project branch to test it out -- but have a couple questions if you don't mind.

I'm struggling with the removal of Proxies -- are there any plans for a similar system, or revisions to the decimation? I like the automatic decimation, but I find that there isn't near the control that was available with proxies. For example, my cloth meshes rely on specific groups for attachment points, like the rays of a battened sail, or the corners where ropes would attach. Decimation on my more detailed meshes often causes these points to be far off from where they should be, or causes topology lines to become very wobbly due to merging inconsistently up and down when parallel lines of vertices are present. It would be nice to exclude vertex groups from decimation, or have a method of ensuring the shape of the mesh isn't overly affected.

I didn't see any method for controlling this, do you have any suggestions?

Secondly, it seems that ambient force zones have been removed -- is it preferred to have a wind force zone follow affected objects around, or to set wind directly through the solver?

I've attached a beautifully rendered version of my struggle with blueprints. The left indicates the result gained via the Obi 6 method, with the red dots representing vertices on the simplified mesh. The central black line is a group used for particle attachment, and the red corner is a point were a rope would attach.

On the right is a somewhat dramatized example of what I'm encountering through decimation.

   

Print this item

  Rope extension, vibration and collision
Posted by: 0hsyn1 - 19-04-2025, 08:00 AM - Forum: Obi Rope - Replies (26)

Hello,
I am developing a project using the system in your Hook project as a reference. I can lengthen and shorten the rope, but the rope has problems interacting with colliders, as far as I understand the particle count is low. How can I increase this? If my method is wrong, please tell me.
When I wrap it around an obstacle, the rope vibrates.

Example of the project I am trying to make: https://play.google.com/store/apps/detai...lley&pli=1

Point A is fixed, point B is moveable.

Thank you Sonrisa

           

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

public class RopeCreate : MonoBehaviour
{
 

    [Header("Obi")]
    [SerializeField] Transform ropeEnd;
    public ObiSolver solver;
    public ObiCollider2D character;
    public float hookExtendRetractSpeed = 2;
    public Material material;
    public ObiRopeSection section;

    private ObiRope rope;
    private ObiRopeBlueprint blueprint;
    private ObiRopeExtrudedRenderer ropeRenderer;

    private ObiRopeCursor cursor;

    private RaycastHit hookAttachment;

    public Rigidbody2D characterRb;
    void Awake()
    {

        // Create both the rope and the solver:    
        rope = gameObject.AddComponent<ObiRope>();
        ropeRenderer = gameObject.AddComponent<ObiRopeExtrudedRenderer>();
        ropeRenderer.section = section;
        ropeRenderer.uvScale = new Vector2(1, 5);
        ropeRenderer.normalizeV = false;
        ropeRenderer.uvAnchor = 1;
        rope.GetComponent<MeshRenderer>().material = material;

        // Setup a blueprint for the rope:
        blueprint = ScriptableObject.CreateInstance<ObiRopeBlueprint>();
        blueprint.resolution = 0.5f;

        // Tweak rope parameters:
        rope.maxBending = 0.02f;

        // Add a cursor to be able to change rope length:
        cursor = rope.gameObject.AddComponent<ObiRopeCursor>();
        cursor.cursorMu = 0;
        cursor.direction = true;
    }

    private void Start()
    {
      

        if (!rope.isLoaded)
            LaunchHook();

        Debug.Log(GetRopeLength());
    }

    private void OnDestroy()
    {
        DestroyImmediate(blueprint);
    }

    /**
     * Raycast against the scene to see if we can attach the hook to something.
     */
    private void LaunchHook()
    {


        StartCoroutine(AttachHook());


    }

    private IEnumerator AttachHook()
    {

        yield return null;

        Vector3 startLocal = transform.position;
        Vector3 endLocal = ropeEnd.position;
        Vector3 direction = (endLocal - startLocal).normalized;

       
        blueprint.path.Clear();
        blueprint.path.AddControlPoint(startLocal, -direction, direction, Vector3.up, 0.1f, 0.1f, 1, 1, Color.white, "Hook start");
        blueprint.path.AddControlPoint(endLocal, -direction, direction, Vector3.up, 0.1f, 0.1f, 1, 1, Color.white, "Hook end");
        blueprint.path.FlushEvents();

       
        yield return blueprint.Generate();

        rope.ropeBlueprint = blueprint;
        rope.GetComponent<MeshRenderer>().enabled = true;

       
        var pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
        pinConstraints.Clear();
        var batch = new ObiPinConstraintsBatch();

       
        batch.AddConstraint(rope.solverIndices[0], character, transform.localPosition, Quaternion.identity, 0, 0, float.PositiveInfinity);

       
        batch.AddConstraint(rope.solverIndices[blueprint.activeParticleCount - 1],
                            ropeEnd.GetComponent<ObiColliderBase>(),
                            //ropeEnd.position,
                            //ropeEnd.InverseTransformPoint(ropeStart.position),
                            Vector3.zero,
                            Quaternion.identity, 0, 0, float.PositiveInfinity);

        batch.activeConstraintCount = 2;
        pinConstraints.AddBatch(batch);

        rope.SetConstraintsDirty(Oni.ConstraintType.Pin);
    } 

  
    public void RopeIncrease()
    {
        cursor.ChangeLength(rope.restLength + hookExtendRetractSpeed * Time.deltaTime);
    }
    public void RopeDecrease()
    {
        cursor.ChangeLength(rope.restLength - hookExtendRetractSpeed * Time.deltaTime );

    }

    public float GetStrain()
    {
        float strain = rope.restLength / rope.CalculateLength();
        return strain;
    }

    public float GetRopeLength()
    {
        return rope.CalculateLength();
    }
}

Code:
public class CapsuleMove : MonoBehaviour
{
    [SerializeField]RopeCreate ropeCreate;
    [Header("Move")]
    const float speed = 500f;
   
    private Vector3 mOffset;
    private float mZCoord;
    private bool active;
    private Rigidbody2D rb;
    float startRotation;

    [SerializeField] public bool isRopeLengthMax = false;

    public Vector2 startPos;

    private Vector2 previousPosition;
    private void Start()
    {
        rb = GetComponent<Rigidbody2D>();

      
    }

    private void OnMouseDown()
    {
       

        mZCoord = Camera.main.WorldToScreenPoint(transform.position).z;
        mOffset = transform.position - GetMouseAsWorldPoint();
        active = true;
        rb.velocity = Vector2.zero;
        rb.gravityScale = 0f;
       
        rb.constraints &= ~RigidbodyConstraints2D.FreezePositionX;
        rb.constraints &= ~RigidbodyConstraints2D.FreezePositionY;

    }

    private void OnMouseUp()
    {
        MouseDownEnded();
    }
    private void MouseDownEnded()
    {
        active = false;
        rb.gravityScale = 1f;
        rb.velocity = Vector2.zero;
        // rb.freezeRotation = true;
        rb.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezePositionY | RigidbodyConstraints2D.FreezeRotation;       
    }

    private Vector3 GetMouseAsWorldPoint()
    {
        Vector3 mousePoint = Input.mousePosition;
        mousePoint.z = mZCoord;
        return Camera.main.ScreenToWorldPoint(mousePoint);
    }

    private void FixedUpdate()
    {
       
        if (isRopeLengthMax)
        {
            MouseDownEnded();

            return;
        }
        if (active)
        {

            Vector2 desiredPosition = (Vector2)(GetMouseAsWorldPoint() + mOffset);
            Vector2 direction = desiredPosition - rb.position;
            rb.velocity = direction.magnitude > 0.1f ? direction * Time.fixedDeltaTime * speed : Vector2.zero;

           

            float distanceMoved = Vector2.Distance(rb.position, previousPosition);
            if (distanceMoved < 0.05f)
            {
                return;
            }

            if (ropeCreate.GetStrain() > .9)
            {
                ropeCreate.RopeDecrease();
            }
            else
            {
                ropeCreate.RopeIncrease();
               // Debug.Log("Lenght" + ropeCreate.GetRopeLength());
            }

            previousPosition = rb.position;

        }
    }
}

Print this item

  How to increase stiffness?
Posted by: softphysics - 16-04-2025, 07:27 PM - Forum: Obi Softbody - Replies (1)

I have a soft body that I want to attach to a 3d object. When I work at the scale I want (size of around 0.1 units), it has zero structural integrity. I tried decreasing the mass of the particles but that didn't work. If I work with meshes around size of 1, then I can attach the soft body to an object and it has some structural integrity but it still flops around too much. Tried tweaking lots of params  (e.g. deformation resistancebut still the same. In older versions there was a control to increase connections between particles that has gone now. What I really want to achieve is to be able to interpolate between a rigid and a soft body, e.g. increase the stiffness of the spring programmatically between each particle. Can't see any kind of functionality like this exposed though. Any ideas?

Print this item