The following code change to ObiRopeExtrudedRenderer is a brute force that makes it work with Octane.
Variant of the same strategy works for OBI Cloth as well.
But this should not be needed.
Is there anything that you can think of that's not as horrible as saving the runtime mesh to an asset file on every frame?
Variant of the same strategy works for OBI Cloth as well.
But this should not be needed.
Is there anything that you can think of that's not as horrible as saving the runtime mesh to an asset file on every frame?
Code:
public bool RealtimeMode = true;
private string SaveFile;
private bool MeshFileSaved = false;
[SerializeField] private bool DebugOnePass = false;
private void ClearMeshData()
{
extrudedMesh.Clear();
vertices.Clear();
normals.Clear();
tangents.Clear();
uvs.Clear();
vertColors.Clear();
tris.Clear();
}
private void CommitMeshData()
{
extrudedMesh.SetVertices(vertices);
extrudedMesh.SetNormals(normals);
extrudedMesh.SetTangents(tangents);
extrudedMesh.SetColors(vertColors);
extrudedMesh.SetUVs(0, uvs);
extrudedMesh.SetTriangles(tris, 0, true);
extrudedMesh.MarkModified(); //This should work. But does not
extrudedMesh.UploadMeshData(false); //Adding this should definitely make it work but it does not
#region Brute Force Method
// This brute force method works
// But this is really bad brute force and should not be needed.
if (DebugOnePass ||((!RealtimeMode) && Application.isPlaying))
{
if (DebugOnePass)
{
SaveFile = string.Empty;
}
DebugOnePass = false;
if (string.IsNullOrEmpty(SaveFile))
{
SaveFile = System.Guid.NewGuid().ToString().Replace(@"-", string.Empty);
SaveFile = string.Concat(SaveFile, @".asset");
}
if (MeshFileSaved)
{
AssetDatabase.DeleteAsset(SavePath);
}
AssetDatabase.CreateAsset(extrudedMesh, SavePath);
MeshFileSaved = true;
}
#endregion
}
private string SavePath
{
get
{
return string.Concat(@"Assets/DynamicMeshTemp/", SaveFile);
}
}
private void OnDestroy()
{
if (!string.IsNullOrEmpty(SaveFile))
{
if (MeshFileSaved)
{
AssetDatabase.DeleteAsset(SavePath);
}
}
}