Closed GoogleCodeExporter closed 8 years ago
The friction in the regular CPU version is position based, while the OpenCL
version is using external forces. This is not OK. The GPU version should apply
the friction the same as the CPU, directly projecting the position.
Here is the relevant code of the CPU friction in case you can't find it:
-------------------------------------------------
const btVector3 vr=vb-va; //relative velocity
const btScalar dn=btDot(vr,c.m_cti.m_normal); //surface component
const btVector3 fv=vr-c.m_cti.m_normal*dn; //relative velocity on the surface
//If the friction coefficient times surface velocity component larger than
surface velocity,
then c3 (1-fc) = 0, remaining surface velocity will be zero, otherwise leave
some tangentialsurface velocity
c.m_c3 = fv.length2()<(btFabs(dn)*fc) ? 0: 1-fc;
const btVector3 fv = vr - (cti.m_normal * dn);
// c0 is the impulse matrix, c3 is 1 - the friction coefficient or 0
const btVector3 impulse = c.m_c0 *
(
(vr -
(fv * c.m_c3) +
(cti.m_normal * (dp * c.m_c4))
) * kst
);
c.m_node->m_x -= impulse * c.m_c2; //m_x is the position of the node/vertex
Original comment by erwin.coumans
on 3 Mar 2012 at 8:48
There seem to be issues with the fourth/w component in the patch.
It is better to use the built-in functions for length, normalize, dot etc,
and not override them with custom versions in the kernel.
If the 4th component is not properly initialized on the CPU side, we should fix
it there.
Original comment by erwin.coumans
on 3 Mar 2012 at 8:52
[deleted comment]
I partly applied the patch, to make the Bullet/Demos/SerializeDemo_AMD work, a
modified version of SolveCollisionsAndUpdateVelocitiesSIMDBatched.cl (applying
friction by projecting the position instead of using external forces)
The patch broke the MiniCL version of AppOpenCLClothDemo_Mini, so I didn't
apply any changes to btSoftBodySolver_OpenCL.* and
SolveCollisionsAndUpdateVelocities.cl
See http://code.google.com/p/bullet/source/detail?r=2518
Original comment by erwin.coumans
on 4 Mar 2012 at 10:16
Erwin,
What do mean modified version of
SolveCollisionsAndUpdateVelocitiesSIMDBatched.cl? Who do you mean 'modified'
the cl file?
Original comment by saggitas...@gmail.com
on 4 Mar 2012 at 10:28
The position is updated rather than the (external) force. A few other changes
are made around those lines. See the code around line 222 in the following link:
http://code.google.com/p/bullet/source/diff?spec=svn2518&r=2518&format=side&path
=/trunk/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/SolveCollisi
onsAndUpdateVelocitiesSIMDBatched.cl
Original comment by erwin.coumans
on 4 Mar 2012 at 11:06
[deleted comment]
Eventually the GPU version should apply exactly the same friction as the CPU
version,
as pointed out in comment #1
http://code.google.com/p/bullet/issues/detail?id=594#c1
Hopefully you can help sorting this out?
I'm just applying this patch, so the demos will run reasonably for the new
Bullet 2.80 release.
Original comment by erwin.coumans
on 4 Mar 2012 at 11:10
We will re-implement this from scratch in Bullet 3, see also
https://github.com/bulletphysics/bullet3/issues/15
Original comment by erwin.coumans
on 30 Mar 2014 at 7:35
Original issue reported on code.google.com by
saggitas...@gmail.com
on 24 Jan 2012 at 12:05Attachments: