26 #define WAVEFRONT_SIZE 32
27 #define WAVEFRONT_BLOCK_MULTIPLIER 2
28 #define GROUP_SIZE (WAVEFRONT_SIZE*WAVEFRONT_BLOCK_MULTIPLIER)
29 #define LINKS_PER_SIMD_LANE 16
37 #define MSTRINGIFY(A) #A
39 #include "OpenCLC10/UpdatePositionsFromVelocities.cl"
40 static const char* SolvePositionsCLString =
41 #include "OpenCLC10/SolvePositionsSIMDBatched.cl"
42 static const char* UpdateNodesCLString =
43 #include "OpenCLC10/UpdateNodes.cl"
44 static const char* UpdatePositionsCLString =
45 #include "OpenCLC10/UpdatePositions.cl"
46 static const char* UpdateConstantsCLString =
47 #include "OpenCLC10/UpdateConstants.cl"
48 static const char* IntegrateCLString =
49 #include "OpenCLC10/Integrate.cl"
50 static const char* ApplyForcesCLString =
51 #include "OpenCLC10/ApplyForces.cl"
52 static const char* UpdateFixedVertexPositionsCLString =
53 #include "OpenCLC10/UpdateFixedVertexPositions.cl"
54 static const char* UpdateNormalsCLString =
55 #include "OpenCLC10/UpdateNormals.cl"
56 static const char* VSolveLinksCLString =
57 #include "OpenCLC10/VSolveLinks.cl"
58 static const char* SolveCollisionsAndUpdateVelocitiesCLString =
59 #include "OpenCLC10/SolveCollisionsAndUpdateVelocitiesSIMDBatched.cl"
61 #include "OpenCLC10/OutputToVertexArray.cl"
66 m_cqCommandQue(queue),
98 int newSize = previousSize + numLinks;
174 m_linkData(queue, ctx)
200 int maxPiterations = 0;
201 int maxViterations = 0;
203 for(
int softBodyIndex = 0; softBodyIndex < softBodies.
size(); ++softBodyIndex )
205 btSoftBody *softBody = softBodies[ softBodyIndex ];
236 int maxTriangles = numTriangles;
240 for(
int vertex = 0; vertex < numVertices; ++vertex )
242 Point3 multPoint(softBody->
m_nodes[vertex].m_x.getX(), softBody->
m_nodes[vertex].m_x.getY(), softBody->
m_nodes[vertex].m_x.getZ());
250 float vertexInverseMass = softBody->
m_nodes[vertex].m_im;
251 desc.setInverseMass(vertexInverseMass);
256 for(
int vertex = numVertices; vertex < maxVertices; ++vertex )
263 for(
int triangle = 0; triangle < numTriangles; ++triangle )
267 int vertexIndex0 = (softBody->
m_faces[triangle].m_n[0] - &(softBody->
m_nodes[0]));
268 int vertexIndex1 = (softBody->
m_faces[triangle].m_n[1] - &(softBody->
m_nodes[0]));
269 int vertexIndex2 = (softBody->
m_faces[triangle].m_n[2] - &(softBody->
m_nodes[0]));
281 int maxLinks = numLinks;
287 for(
int link = 0; link < numLinks; ++link )
289 int vertexIndex0 = softBody->
m_links[link].m_n[0] - &(softBody->
m_nodes[0]);
290 int vertexIndex1 = softBody->
m_links[link].m_n[1] - &(softBody->
m_nodes[0]);
309 if ( piterations > maxPiterations )
310 maxPiterations = piterations;
314 if ( viterations > maxViterations )
315 maxViterations = viterations;
318 for(
int vertex = 0; vertex < numVertices; ++vertex )
320 if ( softBody->
m_nodes[vertex].m_im == 0 )
331 if ( numVertices > 0 )
333 for (
int anchorIndex = 0; anchorIndex < softBody->
m_anchors.
size(); anchorIndex++ )
339 nodeInfo.
clVertexIndex = firstVertex + (int)(anchorNode - firstNode);
340 nodeInfo.
pNode = anchorNode;
365 for(
int softBodyIndex = 0; softBodyIndex <
m_softBodySet.
size(); ++softBodyIndex )
395 using namespace Vectormath::Aos;
405 for(
int linkIndex = 0; linkIndex < numLinks; ++linkIndex )
412 float massLSC = (invMass0 + invMass1)/linearStiffness;
415 float restLengthSquared = restLength*restLength;
503 btAssert( 0 &&
"enqueueNDRangeKernel(m_solvePositionsFromLinksKernel)");
540 btAssert( 0 &&
"enqueueNDRangeKernel(m_solveCollisionsAndUpdateVelocitiesKernel)");
558 const char* additionalMacros=
"";
562 char *wavefrontMacros =
new char[256];
566 "-DMAX_NUM_VERTICES_PER_WAVE=%d -DMAX_BATCHES_PER_WAVE=%d -DWAVEFRONT_SIZE=%d -DWAVEFRONT_BLOCK_MULTIPLIER=%d -DBLOCK_SIZE=%d",
587 delete [] wavefrontMacros;
617 for(
int waveIndex = 0; waveIndex < linksForWavefronts.size(); ++waveIndex )
623 while( batch < wavefrontBatches.size() && !placed )
626 bool foundSharedVertex =
false;
627 for(
int link = 0; link < wavefront.
size(); ++link )
630 if( (mapOfVerticesInBatches[batch])[vertices.
vertex0] || (mapOfVerticesInBatches[batch])[vertices.
vertex1] )
632 foundSharedVertex =
true;
636 if( !foundSharedVertex )
638 wavefrontBatches[batch].push_back( waveIndex );
640 for(
int link = 0; link < wavefront.
size(); ++link )
643 (mapOfVerticesInBatches[batch])[vertices.
vertex0] =
true;
644 (mapOfVerticesInBatches[batch])[vertices.
vertex1] =
true;
650 if( batch == wavefrontBatches.size() && !placed )
652 wavefrontBatches.resize( batch + 1 );
653 wavefrontBatches[batch].push_back( waveIndex );
656 mapOfVerticesInBatches.
resize( batch + 1 );
659 mapOfVerticesInBatches[batch].
resize( numVertices+1,
false );
662 for(
int link = 0; link < wavefront.
size(); ++link )
665 (mapOfVerticesInBatches[batch])[vertices.
vertex0] =
true;
666 (mapOfVerticesInBatches[batch])[vertices.
vertex1] =
true;
670 mapOfVerticesInBatches.
clear();
676 int currentSize = vectorToUpdate.
size();
677 for(
int i = indexToRemove; i < (currentSize-1); ++i )
679 vectorToUpdate[i] = vectorToUpdate[i+1];
681 if( currentSize > 0 )
682 vectorToUpdate.
resize( currentSize - 1 );
690 vectorToUpdate.
resize( vectorToUpdate.
size() + 1 );
691 for(
int i = (vectorToUpdate.
size() - 1); i > index; --i )
693 vectorToUpdate[i] = vectorToUpdate[i-1];
695 vectorToUpdate[index] = element;
705 while( index < vectorToUpdate.
size() && vectorToUpdate[index] < element )
709 if( index == vectorToUpdate.
size() || vectorToUpdate[index] != element )
715 for(
int linkIndex = 0; linkIndex < linkData.
getNumLinks(); ++linkIndex )
718 numLinksPerVertex[nodes.vertex0]++;
719 numLinksPerVertex[nodes.vertex1]++;
721 int maxLinksPerVertex = 0;
722 for(
int vertexIndex = 0; vertexIndex < numVertices; ++vertexIndex )
724 maxLinksPerVertex =
btMax(numLinksPerVertex[vertexIndex], maxLinksPerVertex);
726 maxLinks = maxLinksPerVertex;
729 linksFoundPerVertex.
resize( numVertices, 0 );
731 listOfLinksPerVertex.
resize( maxLinksPerVertex * numVertices );
733 for(
int linkIndex = 0; linkIndex < linkData.
getNumLinks(); ++linkIndex )
738 int vertexIndex = nodes.
vertex0;
739 int linkForVertex = linksFoundPerVertex[nodes.vertex0];
740 int linkAddress = vertexIndex * maxLinksPerVertex + linkForVertex;
742 listOfLinksPerVertex[linkAddress] = linkIndex;
744 linksFoundPerVertex[nodes.vertex0] = linkForVertex + 1;
748 int vertexIndex = nodes.vertex1;
749 int linkForVertex = linksFoundPerVertex[nodes.vertex1];
750 int linkAddress = vertexIndex * maxLinksPerVertex + linkForVertex;
752 listOfLinksPerVertex[linkAddress] = linkIndex;
754 linksFoundPerVertex[nodes.vertex1] = linkForVertex + 1;
762 int linksPerWorkItem,
763 int maxLinksPerWavefront,
775 int maxLinksPerVertex = 0;
779 for(
int linkIndex = 0; linkIndex < linkData.
getNumLinks(); ++linkIndex )
782 numVertices =
btMax( numVertices, nodes.vertex0 + 1 );
783 numVertices =
btMax( numVertices, nodes.vertex1 + 1 );
789 numLinksPerVertex.
resize(0);
790 numLinksPerVertex.
resize( numVertices, 0 );
792 generateLinksPerVertex( numVertices, linkData, listOfLinksPerVertex, numLinksPerVertex, maxLinksPerVertex );
797 for(
int vertex = 0; vertex < 10; ++vertex )
799 for(
int link = 0; link < numLinksPerVertex[vertex]; ++link )
801 int linkAddress = vertex * maxLinksPerVertex + link;
809 int currentVertex = 0;
810 int linksProcessed = 0;
817 int nextWavefront = linksForWavefronts.
size();
818 linksForWavefronts.resize( nextWavefront + 1 );
820 verticesForWavefronts.resize( nextWavefront + 1 );
823 linksForWavefront.
resize(0);
827 while( linksProcessed < linkData.
getNumLinks() && linksForWavefront.
size() < maxLinksPerWavefront )
830 for(
int link = 0; link < numLinksPerVertex[currentVertex] && linksForWavefront.
size() < maxLinksPerWavefront; ++link )
832 int linkAddress = currentVertex * maxLinksPerVertex + link;
833 int linkIndex = listOfLinksPerVertex[linkAddress];
838 if( !processedLink[linkIndex] )
840 linksForWavefront.
push_back( linkIndex );
842 processedLink[linkIndex] =
true;
845 if( v0 == currentVertex )
851 if( verticesToProcess.
size() > 0 )
854 currentVertex = verticesToProcess[0];
862 while( processedLink[searchLink] )
870 for(
int link = 0; link < linksForWavefront.
size(); ++link )
880 batchesWithinWaves.resize( batchesWithinWaves.size() + 1 );
884 for(
int link = 0; link < linksForWavefront.
size(); ++link )
886 int linkIndex = linksForWavefront[link];
891 while( batch < batchesWithinWave.size() && !placed )
893 bool foundSharedVertex =
false;
894 if( batchesWithinWave[batch].
size() >= wavefrontSize )
897 foundSharedVertex =
true;
899 for(
int link2 = 0; link2 < batchesWithinWave[batch].size(); ++link2 )
908 foundSharedVertex =
true;
913 if( !foundSharedVertex )
915 batchesWithinWave[batch].push_back( linkIndex );
921 if( batch == batchesWithinWave.size() && !placed )
923 batchesWithinWave.resize( batch + 1 );
924 batchesWithinWave[batch].push_back( linkIndex );
951 int numBatches = wavefrontBatches.
size();
952 m_wavefrontBatchStartLengths.resize(0);
954 for(
int batchIndex = 0; batchIndex < numBatches; ++batchIndex )
956 int wavesInBatch = wavefrontBatches[batchIndex].
size();
957 int nextPrefixSum = prefixSum + wavesInBatch;
958 m_wavefrontBatchStartLengths.push_back(
BatchPair( prefixSum, nextPrefixSum - prefixSum ) );
960 prefixSum += wavesInBatch;
965 m_maxVerticesWithinWave = 0;
970 int batchesInCurrentWave = batchesWithinWaves[waveIndex].
size();
971 int verticesInCurrentWave = verticesForWavefronts[waveIndex].
size();
973 m_maxVerticesWithinWave =
btMax( verticesInCurrentWave, m_maxVerticesWithinWave );
977 m_maxVerticesWithinWave = 16*((m_maxVerticesWithinWave/16)+2);
980 m_wavefrontVerticesGlobalAddresses.resize( m_maxVerticesWithinWave * m_numWavefronts );
1004 int wavefrontCount = 0;
1007 for(
int batchIndex = 0; batchIndex < numBatches; ++batchIndex )
1010 int wavefrontsInBatch = batch.
size();
1013 for(
int wavefrontIndex = 0; wavefrontIndex < wavefrontsInBatch; ++wavefrontIndex )
1016 int originalWavefrontIndex = batch[wavefrontIndex];
1018 int verticesUsedByWavefront = wavefrontVertices.
size();
1023 for(
int vertex = 0; vertex < verticesUsedByWavefront; ++vertex )
1025 m_wavefrontVerticesGlobalAddresses[m_maxVerticesWithinWave * wavefrontCount + vertex] = wavefrontVertices[vertex];
1027 for(
int vertex = verticesUsedByWavefront; vertex < m_maxVerticesWithinWave; ++vertex )
1029 m_wavefrontVerticesGlobalAddresses[m_maxVerticesWithinWave * wavefrontCount + vertex] = -1;
1037 batchesAndVertices.
numVertices = verticesUsedByWavefront;
1038 m_numBatchesAndVerticesWithinWaves[wavefrontCount] = batchesAndVertices;
1042 for(
int wavefrontBatch = 0; wavefrontBatch < batchesWithinWavefront.
size(); ++wavefrontBatch )
1045 int wavefrontBatchSize = linksInBatch.
size();
1049 for(
int linkIndex = 0; linkIndex < wavefrontBatchSize; ++linkIndex )
1051 int originalLinkAddress = linksInBatch[linkIndex];
1053 m_links[batchAddressInTarget + linkIndex] = m_links_Backup[originalLinkAddress];
1054 m_linkStrength[batchAddressInTarget + linkIndex] = m_linkStrength_Backup[originalLinkAddress];
1055 m_linksMassLSC[batchAddressInTarget + linkIndex] = m_linksMassLSC_Backup[originalLinkAddress];
1056 m_linksRestLengthSquared[batchAddressInTarget + linkIndex] = m_linksRestLengthSquared_Backup[originalLinkAddress];
1057 m_linksRestLength[batchAddressInTarget + linkIndex] = m_linksRestLength_Backup[originalLinkAddress];
1058 m_linksMaterialLinearStiffnessCoefficient[batchAddressInTarget + linkIndex] = m_linksMaterialLinearStiffnessCoefficient_Backup[originalLinkAddress];
1066 m_linkVerticesLocalAddresses[batchAddressInTarget + linkIndex] = localPair;
1068 for(
int linkIndex = wavefrontBatchSize; linkIndex <
m_wavefrontSize; ++linkIndex )
1072 m_linkStrength[batchAddressInTarget + linkIndex] = 0.f;
1073 m_linksMassLSC[batchAddressInTarget + linkIndex] = 0.f;
1074 m_linksRestLengthSquared[batchAddressInTarget + linkIndex] = 0.f;
1075 m_linksRestLength[batchAddressInTarget + linkIndex] = 0.f;
1076 m_linksMaterialLinearStiffnessCoefficient[batchAddressInTarget + linkIndex] = 0.f;
1084 localPair.
vertex0 = verticesUsedByWavefront + (linkIndex % 16);
1085 localPair.
vertex1 = verticesUsedByWavefront + (linkIndex % 16);
1086 m_linkVerticesLocalAddresses[batchAddressInTarget + linkIndex] = localPair;
void setFirstTriangle(int firstTriangle)
static void generateBatchesOfWavefronts(btAlignedObjectArray< btAlignedObjectArray< int > > &linksForWavefronts, btSoftBodyLinkData &linkData, int numVertices, btAlignedObjectArray< btAlignedObjectArray< int > > &wavefrontBatches)
int getMaxVerticesPerWavefront()
virtual void setTriangleAt(const TriangleDescription &triangle, int triangleIndex)
btAlignedObjectArray< int > m_linkAddresses
Link addressing information for each cloth.
static void insertUniqueAndOrderedIntoVector(btAlignedObjectArray< T > &vectorToUpdate, T element)
Insert into btAlignedObjectArray assuming the array is ordered and maintaining both ordering and uniq...
btOpenCLBuffer< Vectormath::Aos::Point3 > m_clVertexPosition
btScalar length(const btQuaternion &q)
Return the length of a quaternion.
void createVertices(int numVertices, int clothIdentifier, int maxVertices=0)
Create numVertices new vertices for cloth clothIdentifier maxVertices allows a buffer zone of extra v...
btAlignedObjectArray< float > m_perClothDragFactor
Drag parameter for wind effect on cloth.
virtual bool moveToAccelerator()
Move data from host memory to the accelerator.
virtual bool onAccelerator()
Return true if data is on the accelerator.
void push_back(const T &_Val)
struct _cl_context * cl_context
void solveLinksForPosition(int startLink, int numLinks, float kst, float ti)
virtual void setNumberOfPositionIterations(int iterations)
Set the number of velocity constraint solver iterations this solver uses.
static const char m_clWavefrontVerticesGlobalAddresses(queue, ctx,&m_wavefrontVerticesGlobalAddresses, true)
static Vectormath::Aos::Transform3 toTransform3(const btTransform &transform)
virtual void createTriangles(int numTriangles)
cl_kernel m_normalizeNormalsAndAreasKernel
void setPosition(const Vectormath::Aos::Point3 &position)
virtual void setLinkAt(const LinkDescription &link, int linkIndex)
Insert the link described into the correct data structures assuming space has already been allocated ...
btOpenCLBuffer< LinkNodePair > m_clLinkVerticesLocalAddresses
btOpenCLBuffer< Vectormath::Aos::Point3 > m_clVertexPreviousPosition
virtual bool moveFromAccelerator()
Move data from host memory from the accelerator.
cl_kernel m_solvePositionsFromLinksKernel
static void generateLinksPerVertex(int numVertices, btSoftBodyLinkData &linkData, btAlignedObjectArray< int > &listOfLinksPerVertex, btAlignedObjectArray< int > &numLinksPerVertex, int &maxLinks)
btOpenCLBuffer< float > m_clPerClothFriction
cl_command_queue m_cqCommandQue
btOpenCLBuffer< Vectormath::Aos::Vector3 > m_clVertexForceAccumulator
float & getRestLengthSquared(int linkIndex)
Return reference to rest length squared for link linkIndex as stored on the host. ...
virtual btSoftBodyLinkData & getLinkData()
void generateBatches()
Generate (and later update) the batching for the entire triangle set.
void setMaxTriangles(int maxTriangles)
CLFunctions * m_currentCLFunctions
btAlignedObjectArray< CollisionObjectIndices > m_perClothCollisionObjects
Collision shape details: pair of index of first collision shape for the cloth and number of collision...
int & getTriangleCount(int vertexIndex)
Get access to the array of how many triangles touch each vertex.
static void insertAtIndex(btAlignedObjectArray< T > &vectorToUpdate, int index, T element)
Insert element into vectorToUpdate at index index.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
btOpenCLBuffer< float > m_clLinksRestLengthSquared
btOpenCLBuffer< float > m_clVertexInverseMass
static const char m_linksPerWorkItem(LINKS_PER_SIMD_LANE)
virtual cl_kernel compileCLKernelFromString(const char *kernelSource, const char *kernelName, const char *additionalMacros, const char *srcFileNameForCaching)
Compile a compute shader kernel from a string and return the appropriate cl_kernel object...
SoftBody class to maintain information about a soft body instance within a solver.
float & getLinearStiffnessCoefficient(int linkIndex)
Return reference to linear stiffness coefficient for link linkIndex as stored on the host...
LinkNodePair & getVertexPair(int linkIndex)
Return reference to the vertex index pair for link linkIndex as stored on the host.
CL_API_ENTRY cl_int CL_API_CALL clEnqueueNDRangeKernel(cl_command_queue, cl_kernel, cl_uint, const size_t *, const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *) CL_API_SUFFIX__VERSION_1_0
static const char m_clLinkVerticesLocalAddresses(queue, ctx,&m_linkVerticesLocalAddresses, true)
Class describing a vertex for input into the system.
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
int getKernelCompilationFailures() const
cl_kernel m_updateVelocitiesFromPositionsWithVelocitiesKernel
bool m_shadersInitialized
static const char m_wavefrontSize(WAVEFRONT_SIZE)
cl_kernel m_integrateKernel
static const char * UpdatePositionsFromVelocitiesCLString
virtual ~btSoftBodyLinkDataOpenCLSIMDAware()
btSoftBodyTriangleDataOpenCL m_triangleData
TriangleNodeSet getVertexSet() const
btAlignedObjectArray< btOpenCLAcceleratedSoftBodyInterface * > m_softBodySet
Cloths owned by this solver.
const btScalar & getZ() const
Return the z value.
btAlignedObjectArray< Vectormath::Aos::Vector3 > m_perClothWindVelocity
Wind velocity to be applied normal to all non-static vertices in the solver.
btOpenCLBuffer< CollisionShapeDescription > m_clCollisionObjectDetails
static const size_t workGroupSize
btOpenCLBuffer< float > m_clLinkStrength
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0), to reduce performance overhead of run-time memory (de)allocations.
virtual bool buildShaders()
float & getMassLSC(int linkIndex)
Return reference to the MassLSC value for link linkIndex as stored on the host.
virtual ~btOpenCLSoftBodySolverSIMDAware()
virtual void createLinks(int numLinks)
Allocate enough space in all link-related arrays to fit numLinks links.
static void removeFromVector(btAlignedObjectArray< T > &vectorToUpdate, int indexToRemove)
static const char m_clNumBatchesAndVerticesWithinWaves(queue, ctx,&m_numBatchesAndVerticesWithinWaves, true)
float lengthSqr(const Vector3 &vec)
btSoftBodyWorldInfo * getWorldInfo()
btAlignedObjectArray< Vectormath::Aos::Vector3 > m_perClothAcceleration
Acceleration value to be applied to all non-static vertices in the solver.
static Vectormath::Aos::Vector3 toVector3(const btVector3 &vec)
btAlignedObjectArray< AnchorNodeInfoCL > m_anchorNodeInfoArray
#define WAVEFRONT_BLOCK_MULTIPLIER
int size() const
return the number of elements in the array
const btVector3 & getWindVelocity()
Return the wind velocity for interaction with the air.
Entry in the collision shape array.
cl_kernel m_resetNormalsAndAreasKernel
btOpenCLBuffer< float > m_clLinksMaterialLinearStiffnessCoefficient
static char * OutputToVertexArrayCLString
#define LINKS_PER_SIMD_LANE
static const char m_numWavefronts(0)
static const char m_maxVertex(0)
btAlignedObjectArray< LinkNodePair > m_links
static const char m_maxBatchesWithinWave(0)
virtual void optimize(btAlignedObjectArray< btSoftBody * > &softBodies, bool forceUpdate=false)
Optimize soft bodies in this solver.
void setFirstVertex(int firstVertex)
Class representing a link as a set of three indices into the vertex array.
btOpenCLBuffer< float > m_clLinksMassLSC
cl_kernel m_applyForcesKernel
btAlignedObjectArray< int > m_anchorIndex
const btScalar & getY() const
Return the y value.
cl_kernel m_updateSoftBodiesKernel
static const char m_clLinkStrength(queue, ctx,&m_linkStrength, false)
const btScalar & getX() const
Return the x value.
static const char m_clLinksRestLengthSquared(queue, ctx,&m_linksRestLengthSquared, false)
virtual void changedOnCPU()
float & getRestLength(int linkIndex)
Return reference to the rest length of link linkIndex as stored on the host.
void generateBatches()
Generate (and later update) the batching for the entire link set.
static void computeBatchingIntoWavefronts(btSoftBodyLinkData &linkData, int wavefrontSize, int linksPerWorkItem, int maxLinksPerWavefront, btAlignedObjectArray< btAlignedObjectArray< int > > &linksForWavefronts, btAlignedObjectArray< btAlignedObjectArray< btAlignedObjectArray< int > > > &batchesWithinWaves, btAlignedObjectArray< btAlignedObjectArray< int > > &verticesForWavefronts)
btAlignedObjectArray< float > m_perClothDampingFactor
Velocity damping factor.
CL_API_ENTRY cl_int CL_API_CALL clSetKernelArg(cl_kernel, cl_uint, size_t, const void *) CL_API_SUFFIX__VERSION_1_0
btAlignedObjectArray< float > m_perClothVelocityCorrectionCoefficient
Velocity correction coefficient.
btAlignedObjectArray< float > m_perClothFriction
Friction coefficient for each cloth.
void solveCollisionsAndUpdateVelocities(float isolverdt)
btOpenCLBuffer< Vectormath::Aos::Vector3 > m_clVertexVelocity
btVector3 can be used to represent 3D points and vectors.
void prepareCollisionConstraints()
Sort the collision object details array and generate indexing into it for the per-cloth collision obj...
btOpenCLSoftBodySolverSIMDAware(cl_command_queue queue, cl_context ctx, bool bUpdateAchchoredNodePos=false)
Class describing a link for input into the system.
void clearKernelCompilationFailures()
static const char m_clLinksRestLength(queue, ctx,&m_linksRestLength, false)
btOpenCLBuffer< float > m_clPerClothDampingFactor
static const char m_maxLinksPerWavefront(m_wavefrontSize *m_linksPerWorkItem)
btOpenCLBuffer< float > m_clLinksRestLength
void resize(int newsize, const T &fillData=T())
btAlignedObjectArray< float > m_perClothLiftFactor
Lift parameter for wind effect on cloth.
btSoftBodyLinkDataOpenCLSIMDAware m_linkData
float & getInverseMass(int vertexIndex)
Return a reference to the inverse mass of vertex vertexIndex as stored on the host.
int findLinearSearch(const T &key) const
btOpenCLBuffer< int > m_clWavefrontVerticesGlobalAddresses
void setNumVertices(int numVertices)
Vectormath::Aos::Point3 & getPosition(int vertexIndex)
Return a reference to the position of vertex vertexIndex as stored on the host.
virtual btSoftBodyVertexData & getVertexData()
int getMaxBatchesPerWavefront()
struct _cl_command_queue * cl_command_queue
void setMaxVertices(int maxVertices)
static const char m_clLinksMaterialLinearStiffnessCoefficient(queue, ctx,&m_linksMaterialLinearStiffnessCoefficient, false)
btOpenCLBuffer< Vectormath::Aos::Vector3 > m_clPerClothWindVelocity
void setNumLinks(int numLinks)
static const char m_clLinksMassLSC(queue, ctx,&m_linksMassLSC, false)
const T & btMax(const T &a, const T &b)
void setFirstLink(int firstLink)
cl_kernel m_solveCollisionsAndUpdateVelocitiesKernel
cl_kernel m_updateFixedVertexPositionsKernel
void setNumTriangles(int numTriangles)
btAlignedObjectArray< float > m_perClothMediumDensity
Density of the medium in which each cloth sits.
float dot(const Quat &quat0, const Quat &quat1)
bool m_updateSolverConstants
Variable to define whether we need to update solver constants on the next iteration.
btOpenCLBuffer< float > m_clPerClothVelocityCorrectionCoefficient
void setLinkStrength(float strength)
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
virtual btSoftBodyTriangleData & getTriangleData()
virtual void setLinkAt(const LinkDescription &link, int linkIndex)
Insert the link described into the correct data structures assuming space has already been allocated ...
btOpenCLBuffer< NumBatchesVerticesPair > m_clNumBatchesAndVerticesWithinWaves
btSoftBodyLinkDataOpenCLSIMDAware(cl_command_queue queue, cl_context ctx)
btSoftBodyVertexDataOpenCL m_vertexData
btOpenCLBuffer< int > m_clClothIdentifier
btAlignedObjectArray< Vectormath::Aos::Point3 > m_anchorPosition
cl_kernel m_updatePositionsFromVelocitiesKernel
void setVertexAt(const VertexDescription &vertex, int vertexIndex)
virtual bool moveToAccelerator()
Move data from host memory to the accelerator.
virtual void setNumberOfVelocityIterations(int iterations)
Set the number of velocity constraint solver iterations this solver uses.
cl_kernel m_updateVelocitiesFromPositionsWithoutVelocitiesKernel
void updateConstants(float timeStep)
int m_numberOfPositionIterations
btAlignedObjectArray< BatchPair > m_wavefrontBatchStartLengths
Start and length values for computation batches over link data.
btOpenCLBuffer< CollisionObjectIndices > m_clPerClothCollisionObjects
virtual void createLinks(int numLinks)
Allocate enough space in all link-related arrays to fit numLinks links.
virtual void solveConstraints(float solverdt)
Solve constraints for a set of soft bodies.