Changeset View
Changeset View
Standalone View
Standalone View
extern/bullet2/src/BulletSoftBody/btSoftBodySolvers.h
| Show All 12 Lines | |||||
| 3. This notice may not be removed or altered from any source distribution. | 3. This notice may not be removed or altered from any source distribution. | ||||
| */ | */ | ||||
| #ifndef BT_SOFT_BODY_SOLVERS_H | #ifndef BT_SOFT_BODY_SOLVERS_H | ||||
| #define BT_SOFT_BODY_SOLVERS_H | #define BT_SOFT_BODY_SOLVERS_H | ||||
| #include "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h" | #include "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h" | ||||
| class btSoftBodyTriangleData; | class btSoftBodyTriangleData; | ||||
| class btSoftBodyLinkData; | class btSoftBodyLinkData; | ||||
| class btSoftBodyVertexData; | class btSoftBodyVertexData; | ||||
| class btVertexBufferDescriptor; | class btVertexBufferDescriptor; | ||||
| class btCollisionObject; | class btCollisionObject; | ||||
| class btSoftBody; | class btSoftBody; | ||||
| class btSoftBodySolver | class btSoftBodySolver | ||||
| { | { | ||||
| public: | public: | ||||
| enum SolverTypes | enum SolverTypes | ||||
| { | { | ||||
| DEFAULT_SOLVER, | DEFAULT_SOLVER, | ||||
| CPU_SOLVER, | CPU_SOLVER, | ||||
| CL_SOLVER, | CL_SOLVER, | ||||
| CL_SIMD_SOLVER, | CL_SIMD_SOLVER, | ||||
| DX_SOLVER, | DX_SOLVER, | ||||
| DX_SIMD_SOLVER | DX_SIMD_SOLVER, | ||||
| DEFORMABLE_SOLVER | |||||
| }; | }; | ||||
| protected: | protected: | ||||
| int m_numberOfPositionIterations; | int m_numberOfPositionIterations; | ||||
| int m_numberOfVelocityIterations; | int m_numberOfVelocityIterations; | ||||
| // Simulation timescale | // Simulation timescale | ||||
| float m_timeScale; | float m_timeScale; | ||||
| public: | public: | ||||
| btSoftBodySolver() : | btSoftBodySolver() : m_numberOfPositionIterations(10), | ||||
| m_numberOfPositionIterations( 10 ), | |||||
| m_timeScale( 1 ) | m_timeScale(1) | ||||
| { | { | ||||
| m_numberOfVelocityIterations = 0; | m_numberOfVelocityIterations = 0; | ||||
| m_numberOfPositionIterations = 5; | m_numberOfPositionIterations = 5; | ||||
| } | } | ||||
| virtual ~btSoftBodySolver() | virtual ~btSoftBodySolver() | ||||
| { | { | ||||
| } | } | ||||
| /** | /** | ||||
| * Return the type of the solver. | * Return the type of the solver. | ||||
| */ | */ | ||||
| virtual SolverTypes getSolverType() const = 0; | virtual SolverTypes getSolverType() const = 0; | ||||
| /** Ensure that this solver is initialized. */ | /** Ensure that this solver is initialized. */ | ||||
| virtual bool checkInitialized() = 0; | virtual bool checkInitialized() = 0; | ||||
| /** Optimize soft bodies in this solver. */ | /** Optimize soft bodies in this solver. */ | ||||
| virtual void optimize( btAlignedObjectArray< btSoftBody * > &softBodies , bool forceUpdate=false) = 0; | virtual void optimize(btAlignedObjectArray<btSoftBody *> &softBodies, bool forceUpdate = false) = 0; | ||||
| /** Copy necessary data back to the original soft body source objects. */ | /** Copy necessary data back to the original soft body source objects. */ | ||||
| virtual void copyBackToSoftBodies(bool bMove = true) = 0; | virtual void copyBackToSoftBodies(bool bMove = true) = 0; | ||||
| /** Predict motion of soft bodies into next timestep */ | /** Predict motion of soft bodies into next timestep */ | ||||
| virtual void predictMotion( float solverdt ) = 0; | virtual void predictMotion(btScalar solverdt) = 0; | ||||
| /** Solve constraints for a set of soft bodies */ | /** Solve constraints for a set of soft bodies */ | ||||
| virtual void solveConstraints( float solverdt ) = 0; | virtual void solveConstraints(btScalar solverdt) = 0; | ||||
| /** Perform necessary per-step updates of soft bodies such as recomputing normals and bounding boxes */ | /** Perform necessary per-step updates of soft bodies such as recomputing normals and bounding boxes */ | ||||
| virtual void updateSoftBodies() = 0; | virtual void updateSoftBodies() = 0; | ||||
| /** Process a collision between one of the world's soft bodies and another collision object */ | /** Process a collision between one of the world's soft bodies and another collision object */ | ||||
| virtual void processCollision( btSoftBody *, const struct btCollisionObjectWrapper* ) = 0; | virtual void processCollision(btSoftBody *, const struct btCollisionObjectWrapper *) = 0; | ||||
| /** Process a collision between two soft bodies */ | /** Process a collision between two soft bodies */ | ||||
| virtual void processCollision( btSoftBody*, btSoftBody* ) = 0; | virtual void processCollision(btSoftBody *, btSoftBody *) = 0; | ||||
| /** Set the number of velocity constraint solver iterations this solver uses. */ | /** Set the number of velocity constraint solver iterations this solver uses. */ | ||||
| virtual void setNumberOfPositionIterations( int iterations ) | virtual void setNumberOfPositionIterations(int iterations) | ||||
| { | { | ||||
| m_numberOfPositionIterations = iterations; | m_numberOfPositionIterations = iterations; | ||||
| } | } | ||||
| /** Get the number of velocity constraint solver iterations this solver uses. */ | /** Get the number of velocity constraint solver iterations this solver uses. */ | ||||
| virtual int getNumberOfPositionIterations() | virtual int getNumberOfPositionIterations() | ||||
| { | { | ||||
| return m_numberOfPositionIterations; | return m_numberOfPositionIterations; | ||||
| } | } | ||||
| /** Set the number of velocity constraint solver iterations this solver uses. */ | /** Set the number of velocity constraint solver iterations this solver uses. */ | ||||
| virtual void setNumberOfVelocityIterations( int iterations ) | virtual void setNumberOfVelocityIterations(int iterations) | ||||
| { | { | ||||
| m_numberOfVelocityIterations = iterations; | m_numberOfVelocityIterations = iterations; | ||||
| } | } | ||||
| /** Get the number of velocity constraint solver iterations this solver uses. */ | /** Get the number of velocity constraint solver iterations this solver uses. */ | ||||
| virtual int getNumberOfVelocityIterations() | virtual int getNumberOfVelocityIterations() | ||||
| { | { | ||||
| return m_numberOfVelocityIterations; | return m_numberOfVelocityIterations; | ||||
| Show All 15 Lines | |||||
| /** | /** | ||||
| * Class to manage movement of data from a solver to a given target. | * Class to manage movement of data from a solver to a given target. | ||||
| * This version is abstract. Subclasses will have custom pairings for different combinations. | * This version is abstract. Subclasses will have custom pairings for different combinations. | ||||
| */ | */ | ||||
| class btSoftBodySolverOutput | class btSoftBodySolverOutput | ||||
| { | { | ||||
| protected: | protected: | ||||
| public: | public: | ||||
| btSoftBodySolverOutput() | btSoftBodySolverOutput() | ||||
| { | { | ||||
| } | } | ||||
| virtual ~btSoftBodySolverOutput() | virtual ~btSoftBodySolverOutput() | ||||
| { | { | ||||
| } | } | ||||
| /** Output current computed vertex data to the vertex buffers for all cloths in the solver. */ | /** Output current computed vertex data to the vertex buffers for all cloths in the solver. */ | ||||
| virtual void copySoftBodyToVertexBuffer( const btSoftBody * const softBody, btVertexBufferDescriptor *vertexBuffer ) = 0; | virtual void copySoftBodyToVertexBuffer(const btSoftBody *const softBody, btVertexBufferDescriptor *vertexBuffer) = 0; | ||||
| }; | }; | ||||
| #endif // #ifndef BT_SOFT_BODY_SOLVERS_H | #endif // #ifndef BT_SOFT_BODY_SOLVERS_H | ||||