NVIDIAGameWorks / PhysX-3.4

NVIDIA PhysX SDK 3.4
https://www.nvidia.com/
2.35k stars 277 forks source link

A question for SwSloverKernel.cpp #41

Closed yuebingzero closed 7 years ago

yuebingzero commented 7 years ago

In PhysX-3.4\PhysX_3.4\Source\LowLevelCloth\src\SwSolverKernel.cpp, line 209

curPos0 = curPos0 & (splat<0>(radius) > sMinusFloatMaxXYZ);
curPos1 = curPos1 & (splat<1>(radius) > sMinusFloatMaxXYZ);
curPos2 = curPos2 & (splat<2>(radius) > sMinusFloatMaxXYZ);
curPos3 = curPos3 & ((radius) > sMinusFloatMaxXYZ);

why not ?

curPos0 = curPos0 & (splat<0>(radius) > sMinusFloatMaxXYZ);
curPos1 = curPos1 & (splat<1>(radius) > sMinusFloatMaxXYZ);
curPos2 = curPos2 & (splat<2>(radius) > sMinusFloatMaxXYZ);
curPos3 = curPos3 & (**splat<3>**(radius) > sMinusFloatMaxXYZ);
mtamis-NV commented 7 years ago

Hi, Thanks for pointing that out, however I think that the code is correct. Did you notice any particular problem in the simulation? I'll add some comments to make it easier to understand:

// set invMass to zero if radius is zero (xyz will be unchanged)
// curPos.w = radius > 0 ? curPos.w : 0
// the first three components are compared against -FLT_MAX which is always true
curPos0 = curPos0 & (splat<0>(radius) > sMinusFloatMaxXYZ);
curPos1 = curPos1 & (splat<1>(radius) > sMinusFloatMaxXYZ);
curPos2 = curPos2 & (splat<2>(radius) > sMinusFloatMaxXYZ);
curPos3 = curPos3 & ((radius) > sMinusFloatMaxXYZ);
// we don't have to splat the last one as the 4th element is already in the right place

Note that clothing in PhysX is deprecated, so this change will only be made in NvCloth.