Cloth资产用Brush刷MaxDistance,如果有的顶点或线段在PhysicalMeshWireframe和PariticleIndices预览视图下显示为粉色,在荣耀X20SE手机上就会顶点乱飞。
由FClothVisualization::DrawPhysMeshWired可知,粉色表示InvM为0。
经过追查发现是在FClothingSimulationSolver::ParticleMassClampAndKinematicStateUpdate中计算Cloth的InvM,这里可能出现1除以0的情况,直到5.7版本这段代码都是如下所示。
请问可以在此处判断如果Particles.M(Index)为0,则InvM设为0吗?是否会有其他风险,或是否有更好的地方修复此bug?
<br/>
void FClothingSimulationSolver::ParticleMassClampAndKinematicStateUpdate(Softs::FSolverParticlesRange& Particles, Softs::FSolverReal MinPerParticleMass, const TFunctionRef<bool(int32)>& KinematicPredicate)
{
for (int32 Index = 0; Index < Particles.GetRangeSize(); ++Index)
{
Particles.M(Index) = FMath::Max(Particles.M(Index), MinPerParticleMass);
Particles.InvM(Index) = KinematicPredicate(Index) ? (Softs::FSolverReal)0. : (Softs::FSolverReal)1. / Particles.M(Index);
}
}
[Attachment Removed]