05-12-2021, 07:48 PM
Hi,
I am currently making a simple mesh work with the cloth simulation using custom meshes made through unity. The mesh I am currently using is extremely simple of two rectangles that are stitched together using Obistitcher. The problem I am having however is that the mesh flies away immediately after I start simulating (I am also using a custom obiupdater to handle the simulation) and I am not sure what is causing this.
Here is the example of whats occuring https://youtu.be/xJC8gUavDDA
Custom ObiUpdater
I am currently making a simple mesh work with the cloth simulation using custom meshes made through unity. The mesh I am currently using is extremely simple of two rectangles that are stitched together using Obistitcher. The problem I am having however is that the mesh flies away immediately after I start simulating (I am also using a custom obiupdater to handle the simulation) and I am not sure what is causing this.
Here is the example of whats occuring https://youtu.be/xJC8gUavDDA
Custom ObiUpdater
Code:
private void Awake()
{
_currentSimulationTime = 0;
if (solvers == null)
solvers.Add(gameObject.GetComponent<ObiSolver>());
}
[ContextMenu("Toggle Simulation")]
public void ToggleSimulate() => isSimulating = !isSimulating;
private void FixedUpdate()
{
if (!isSimulating)
return;
if (_currentSimulationTime >= _simulateTime)
{
isSimulating = false;
return;
}
BeginStep(Time.fixedDeltaTime);
float substepDelta = Time.fixedDeltaTime / _substeps;
for (int i = 0; i < _substeps; ++i)
Substep(Time.fixedDeltaTime,substepDelta,_substeps - i);
EndStep(substepDelta);
Interpolate(2, 100);
_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;
}
}