Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Mesh Flies away on Simulation
#3
Hi!

Thanks for the assistance for the obiupdater I definitely was unaware of what I was completely doing exactly so I referred to the obiupdaters and what you have mentioned and updated my updater and now it does seem to run better however unfortunately the original problem still persists. 

Would you have any other idea to what else it might be? 

Here is the generation for the mesh and its obicloth blueprint

Code:
public void Initialise(MeshData data)
        {
            _data = data;
           StartCoroutine(InitialiseCoroutine());
        }
       
     

        IEnumerator InitialiseCoroutine()
        {
            _mesh = new Mesh();

           
           
            var vertexes = new List<Vector3>();

            foreach (var vertex in _data.Vertices)
                vertexes.Add(vertex.Position);

            _mesh.vertices = vertexes.ToArray();
            _mesh.uv = _data.UVs;
            _mesh.triangles = _data.Triangles;
            _meshFilter.mesh = _mesh;

            _meshRenderer.material = _data.Fabric.Material;

            _meshCollider.sharedMesh = _mesh;
            _collider.sourceCollider = _meshCollider;

            _solver.AddActor(_actor);
       
            var blueprint = _actor.blueprint as ObiClothBlueprint;
            blueprint.inputMesh = _mesh;

            yield return StartCoroutine(GenerateBlueprintCoroutine(blueprint));
        }

        IEnumerator GenerateBlueprintCoroutine(ObiClothBlueprint blueprint)
        {
            yield return StartCoroutine(blueprint.Generate());
            GetComponent<ObiCloth>().clothBlueprint = blueprint;
            HasGeneratedBlueprint = true;
            //_solver.UpdateBackend();
        }


New Updater

Code:
   private void FixedUpdate()
        {
            if (!isSimulating)
                return;
           
            if (_currentSimulationTime >= _simulateTime)
            {
                isSimulating = false;
                return;
            }
           
            ObiProfiler.EnableProfiler();

           
            BeginStep(Time.fixedDeltaTime);

            float substepDelta = Time.fixedDeltaTime / _substeps;

            for (int i = 0; i < _substeps; ++i)
                Substep(Time.fixedDeltaTime,substepDelta,_substeps - i);
           
            EndStep(substepDelta);

            ObiProfiler.DisableProfiler();

            _currentSimulationTime -= Time.fixedDeltaTime;

        }

        private void Update()
        {
            if (!isSimulating)
            {
                if (_currentSimulationTime >= _simulateTime)
                {
                    _currentSimulationTime = 0f;
                    gameObject.GetComponent<MeshController>().BakeMesh();
                }
                 
                return;
            }
           
            if (_currentSimulationTime >= _simulateTime)
            {
                isSimulating = false;
                return;
            }
           
            ObiProfiler.EnableProfiler();
            Interpolate(Time.fixedDeltaTime,_currentSimulationTime);
            ObiProfiler.DisableProfiler();

            _currentSimulationTime += Time.deltaTime;

        }
       
    }
Reply


Messages In This Thread
Mesh Flies away on Simulation - by Biggerest - 05-12-2021, 07:48 PM
RE: Mesh Flies away on Simulation - by josemendez - 06-12-2021, 11:15 AM
RE: Mesh Flies away on Simulation - by Biggerest - 08-12-2021, 05:44 PM
RE: Mesh Flies away on Simulation - by josemendez - 10-12-2021, 09:42 AM