Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flipping cloth? ScaleX == -1?
#6
(14-08-2019, 04:48 PM)cubrman Wrote: The only thing I am baffled about is this: why don't you just let me try and see for myself? Just tell me the best case scenario the best way to do what I want to do and let me fail on my own. Maybe then I will have other ideas. Flipping normals in the shader isn't hard for me - I am worried about cloth mesh jumping into colliders after flip though.

Huh I'm not holding you back in any way?. Simulation is done in FixedUpdate(), after WaitForFixedUpdate(), or in LateUpdate(), depending on your solver's update order. If you want to flip the mesh after simulation is done, then by all means go ahead. I'm just telling you it won't work in advance to save you headaches, explaining you why, and giving you a reasonable alternative.

The "clothMesh" property of ObiCloth contains the deformed mesh, just grab it and modify it in any way you want. Assuming your solver is updating the simulation in FixedUpdate, you can grab the results in Update, which is called by Unity always after FixedUpdate. Like:

Code:
void Update()
{
  Mesh mesh = cloth.clothMesh;
  // modify the mesh here
}

Quote:Flipping normals in the shader isn't hard for me - I am worried about cloth mesh jumping into colliders after flip though.
If you flip the normals in the shader, you cannot affect the simulation in any way if that's what you're worried about, only rendering. So the mesh won't jump into colliders or anything, if you only modify its shader.

Of course you could also flip the normals in Update as well (or scale the vertices of the mesh directly, one by one), but it would be staggeringly slow compared to using the vertex shader. (Note Obi performs mesh deformation in native code for performance reasons).
Reply


Messages In This Thread
Flipping cloth? ScaleX == -1? - by cubrman - 13-08-2019, 05:29 PM
RE: Flipping cloth? ScaleX == -1? - by josemendez - 14-08-2019, 09:10 AM
RE: Flipping cloth? ScaleX == -1? - by cubrman - 14-08-2019, 11:11 AM
RE: Flipping cloth? ScaleX == -1? - by josemendez - 14-08-2019, 12:19 PM
RE: Flipping cloth? ScaleX == -1? - by cubrman - 14-08-2019, 04:48 PM
RE: Flipping cloth? ScaleX == -1? - by josemendez - 14-08-2019, 05:30 PM
RE: Flipping cloth? ScaleX == -1? - by cubrman - 22-08-2019, 06:13 PM
RE: Flipping cloth? ScaleX == -1? - by josemendez - 23-08-2019, 07:17 AM
RE: Flipping cloth? ScaleX == -1? - by cubrman - 23-08-2019, 10:03 AM
RE: Flipping cloth? ScaleX == -1? - by josemendez - 23-08-2019, 10:05 AM
RE: Flipping cloth? ScaleX == -1? - by josemendez - 23-08-2019, 10:35 AM
RE: Flipping cloth? ScaleX == -1? - by cubrman - 23-08-2019, 12:10 PM
RE: Flipping cloth? ScaleX == -1? - by josemendez - 23-08-2019, 01:06 PM