Search Forums

(Advanced Search)

Latest Threads
Rope Jittering/ Stutterin...
Forum: Obi Rope
Last Post: Nixon
4 hours ago
» Replies: 2
» Views: 13
Advection but for a mesh.
Forum: Obi Fluid
Last Post: spikebor
Today, 09:28 AM
» Replies: 0
» Views: 13
Tips for optimization usi...
Forum: Obi Softbody
Last Post: spikebor
Today, 09:14 AM
» Replies: 0
» Views: 10
Obi Fluid 6 not render on...
Forum: Obi Fluid
Last Post: spikebor
Yesterday, 07:41 PM
» Replies: 3
» Views: 64
Question about garment on...
Forum: Obi Cloth
Last Post: josemendez
Yesterday, 01:03 PM
» Replies: 21
» Views: 612
Attaching a rope and upda...
Forum: Obi Rope
Last Post: Alexander34
Yesterday, 12:58 PM
» Replies: 5
» Views: 496
I've made a bounce script...
Forum: Obi Softbody
Last Post: spikebor
01-05-2024, 04:39 PM
» Replies: 3
» Views: 80
Prefab Creation & Cable L...
Forum: Obi Rope
Last Post: josemendez
01-05-2024, 01:12 PM
» Replies: 5
» Views: 98
Error: Particle that does...
Forum: Obi Rope
Last Post: josemendez
01-05-2024, 10:39 AM
» Replies: 1
» Views: 40
Setup Ignore Collisions b...
Forum: Obi Softbody
Last Post: spikebor
30-04-2024, 07:15 PM
» Replies: 4
» Views: 99

 
  App crash after RemoveFromSolver called [4.0.2 and older]
Posted by: mmortall - 26-02-2019, 01:40 PM - Forum: Obi Cloth - Replies (7)

I had the same crash on older versions. And I already posted information about it in other my threads. But finally I was able to reproduce crash with 80-100% repo rate and I've found the source of it. 

To reproduce open your example RuntimeCloth.scene. Replace SackGenerator.cs content with code in this post below.

This code just call RemoveFromSolver for all generated cloth after 2 seconds and you can add unlimited amount of cloth when press SPACE button.
Crash occurs after RemoveFromSolver called with some delay (1-5 sec) but you have to do it a couple of time to get crash 100%. On my PC it takes 1-4 tries. 
Sometimes you will have some Unity errors popping up in random places. And then you get crash. Also occurs in standalone version. On Mac OS and Windows. My Unity is 2018.3.0f2
This is a very big blocker for us currently. Because we create lots of objects in runtime and we need to remove them from solver and add again for resimulation.
I am also not able to resimulate ObiActor in 4.0.2 using same solver but I will try some other ways and open a new thread about it if I fail. But first this issue need to be handled.

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

/**
* Generates a fully procedural cloth sack at runtime. This is done by generating two meshes
* and using RuntimeClothGenerator to create cloth out of both of them. Then they are sewn together using
* the ObiStitcher component.
*/
public class SackGenerator : MonoBehaviour {

    public ObiSolver solver;                /**< solver to add the sack to.*/
    public ObiMeshTopology topology;        /**< empty topology asset used to store sack mesh information.*/
    public Material outsideMaterial;                /**< material used for rendering the sack.*/
    public Material insideMaterial;                /**< material used for rendering the sack.*/
    public float sackSize = 1;                 /**< size of the sack in world units.*/
    public int resolution = 10;           /**< resolution of sack mesh in quads per side.*/
    
    
    private List<ObiCloth> _GeneratedActors = new List<ObiCloth>();

    /**
    * Generates and returns procedural tesselated square mesh.
    */
    private Mesh GenerateSheetMesh(){

        // create a new mesh:
        Mesh mesh = new Mesh();
        mesh.name = "sack_sheet";

        float quadSize = sackSize/resolution;
        
        int vertexCount = (resolution + 1) * (resolution + 1);
        int triangleCount = resolution * resolution * 2;
        Vector3[] vertices = new Vector3[vertexCount];
        Vector3[] normals = new Vector3[vertexCount];
        Vector4[] tangents = new Vector4[vertexCount];
        Vector2[] uvs = new Vector2[vertexCount];
        int[] triangles = new int[triangleCount * 3];
        
        // generate vertices:
        // for each row:
        for (int y = 0; y < resolution+1; ++y){
            // for each column:
            for (int x = 0; x < resolution+1; ++x){
                int v = y*(resolution+1)+x;
                vertices[v] = new Vector3(quadSize*x,quadSize*y,0);
                normals[v] = Vector3.forward;
                tangents[v] = new Vector4(1,0,0,1);
                uvs[v] = new Vector3(x/(float)resolution,y/(float)resolution);
            }
        }

        // generate triangle faces:
        for (int y = 0; y < resolution; ++y){
            // for each column:
            for (int x = 0; x < resolution; ++x){

                int face = (y*(resolution+1)+x);
                int t = (y*resolution+x)*6;

                triangles[t] = face;
                triangles[t+1] = face+1;
                triangles[t+2] = face+resolution+1;
        
                triangles[t+3] = face+resolution+1;
                triangles[t+4] = face+1;
                triangles[t+5] = face+resolution+2;
            }
        }
    
        mesh.vertices = vertices;
        mesh.normals = normals;
        mesh.tangents = tangents;
        mesh.uv = uvs;
        mesh.triangles = triangles;
        mesh.RecalculateBounds();
        return mesh;
    }

    private void GenerateSack(){

        Mesh mesh = GenerateSheetMesh();

        // create and give a material to both sides of the sack:
        GameObject sheet1 = new GameObject("sack_side1",typeof(MeshFilter),typeof(MeshRenderer));
        sheet1.GetComponent<MeshRenderer>().materials = new Material[]{outsideMaterial,insideMaterial};

        GameObject sheet2 = new GameObject("sack_side2",typeof(MeshFilter),typeof(MeshRenderer));
        sheet2.GetComponent<MeshRenderer>().materials = new Material[]{outsideMaterial,insideMaterial};

        // position both sheets around the center of this object:
        sheet1.transform.parent = transform;
        sheet2.transform.parent = transform;
        sheet1.transform.localPosition = Vector3.forward;
        sheet2.transform.localPosition = -Vector3.forward;

        // generate cloth for both of them:
        RuntimeClothGenerator generator1 = sheet1.AddComponent<RuntimeClothGenerator>();
        generator1.solver = solver;
        generator1.topology = topology;
        generator1.mesh = mesh;

        RuntimeClothGenerator generator2 = sheet2.AddComponent<RuntimeClothGenerator>();
        generator2.solver = solver;
        generator2.topology = topology;
        generator2.mesh = mesh;

        // sew both sides together:
        ObiStitcher stitcher = gameObject.AddComponent<ObiStitcher>();
        stitcher.Actor1 = sheet1.GetComponent<ObiCloth>();
        stitcher.Actor2 = sheet2.GetComponent<ObiCloth>();

        // add stitches: top and bottom edges:
        for (int i = 1; i < resolution; ++i){
            stitcher.AddStitch(i,i);
            stitcher.AddStitch((resolution+1)*resolution + i,(resolution+1)*resolution + i);
        }

        // sides:
        for (int i = 0; i <= (resolution+1)*resolution; i+=resolution+1){
            stitcher.AddStitch(i,i);
            stitcher.AddStitch(i + resolution ,i + resolution );
        }

        // adjust bending constraints to obtain a little less rigid fabric:
        ObiCloth cloth1 = sheet1.GetComponent<ObiCloth>();
        ObiCloth cloth2 = sheet2.GetComponent<ObiCloth>();

        cloth1.BendingConstraints.maxBending = 0.02f;
        cloth2.BendingConstraints.maxBending = 0.02f;

        cloth1.BendingConstraints.PushDataToSolver(ParticleData.NONE);
        cloth2.BendingConstraints.PushDataToSolver(ParticleData.NONE);

        _GeneratedActors.Add(cloth1);
        _GeneratedActors.Add(cloth2);
    }

    public void Update(){

        if (Input.GetKeyDown(KeyCode.Space))
        {
            GenerateSack();
            
            Invoke("RemoveAllGenerated", 2.0f);
        }
    }

    public void RemoveAllGenerated()
    {
        foreach (var actor in _GeneratedActors)
        {
            actor.RemoveFromSolver(null);
        }
    }
}

I am not attaching a Crash Log because all times it is different because of memory corruption. But it happens 100% after RemoveFromSolver was called.

Print this item

  Normalized rope position?
Posted by: camirving - 25-02-2019, 09:29 PM - Forum: Obi Rope - Replies (1)

Hi there!

I have a rope and i've expanded its length.

I want to get the position of the particle that sits in the very middle of the rope, in normalized 0.5.

How can I retrieve a particle position via normalized value?

Print this item

  Obi 4.0.2 compile errors
Posted by: mmortall - 25-02-2019, 03:01 PM - Forum: General - Replies (4)

Adding Obi 4.0.2 to new project got compile errors in Editor:

Assets\Plugins\Obi\Scripts\Actors\ObiEmitter.cs(296,73): error CS0426: The type name 'MaterialChangeEventArgs' does not exist in the type 'ObiEmitterMaterial'
Assets\Plugins\Obi\Scripts\Actors\ObiEmitter.cs(91,24): error CS0115: 'ObiEmitter.Awake()': no suitable method found to override

Assets\Plugins\Obi\Scripts\Utils\ObiClothDragger.cs(45,9): error CS0117: 'Oni' does not contain a definition for 'GetParticlePositions'

Unity 2018.3.0f2

Print this item

  particles wont stop moving
Posted by: drorlazar - 24-02-2019, 09:51 AM - Forum: Obi Cloth - Replies (4)

Hi there
I'm using cloth as a hair simulation. i'm trying to achieve a smooth grad of movement so it'll look organic and no matter how i try to reduce the particles mass/skin radius/ backstop/backstop radius/skin stiffness and what not, they are still getting a lot of motion. 
any ideas /tutorials about how to create a smooth transition from a skinned vertices to a simulated ones? 

(we've purchase both cloth and softbody, the guy in charge of purchasing them will send me the invoice/order number later today)

Print this item

  Cloth stop working once adding another solver/mesh
Posted by: drorlazar - 24-02-2019, 09:45 AM - Forum: Obi Cloth - Replies (3)

Hi there
I have a cloth mesh in my scene as a hair simulation (local space).
 when i try to add another cloth component to the scene (this time in the pants of the character) the hair stops working, i've tried to add another solver for the new cloth but without help. when adding another solver/cloth comp to the scene the first cloth stop working. 
and ideas what can cause that? 

(we've purchase both cloth and softbody, the guy in charge of purchasing them will send me the invoice/order number later today)

Print this item

  Run time Character Clothing
Posted by: VrTech - 24-02-2019, 07:50 AM - Forum: Obi Cloth - Replies (11)

Hi, 

Is there any way to make a cloth for the character on runtime?
I want to instantiate my character in multiplayer.

Thank you.

Print this item

  Constrain particles on axis
Posted by: Richard - 22-02-2019, 09:38 AM - Forum: Obi Cloth - Replies (14)

Can I constrain particles on x, y or z axis?

Print this item

  Cloth simulation slightly delayed
Posted by: VrTech - 21-02-2019, 08:57 PM - Forum: Obi Cloth - Replies (3)

The problem is when I trigger the obiCloth On it's slowly follow up. I don't know why?

[attachment=257]

This is when ObiCloh is Turn Off
[Image: giphy.gif]

And this is when it turned on
[Image: giphy.gif]


Any ideas?

Thank you!

Print this item

  Weird movement of obi cloth
Posted by: Richard - 21-02-2019, 10:01 AM - Forum: Obi Cloth - Replies (6)

Hello. I attached obi cloth to the dress. It starts rotating at runtime like the image(left one is original) and shrink even though I did not do such setting. Can you solve the problem?

Print this item

  2D softbody physics example
Posted by: tunageXD - 20-02-2019, 05:04 PM - Forum: Obi Softbody - Replies (2)

I wish to integrate softbody physics into my project using 2d sprites and 2d colliders.

For example I want softbody physics on a 2d sprite that will deform when 2d sprite projectiles collide with it. Would I need to convert all of these sprites to skinned mesh? If so what would be the best way to achieve this?

I cannot find any applicable documentation or example of how to achieve this.

Any help would be greatly appreciated!

Print this item