Bullet Collision Detection & Physics Library: btSoftBodySolvers.h Source File

Bullet Collision Detection & Physics Library

btSoftBodySolvers.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16 #ifndef BT_SOFT_BODY_SOLVERS_H
17 #define BT_SOFT_BODY_SOLVERS_H
18
19 #include "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h"
20
21
22 class btSoftBodyTriangleData;
23 class btSoftBodyLinkData;
24 class btSoftBodyVertexData;
25 class btVertexBufferDescriptor;
26 class btCollisionObject;
27 class btSoftBody;
28
29
30 class btSoftBodySolver
31 {
32 public:
33 enum SolverTypes
34 {
35 DEFAULT_SOLVER,
36 CPU_SOLVER,
37 CL_SOLVER,
38 CL_SIMD_SOLVER,
39 DX_SOLVER,
40 DX_SIMD_SOLVER
41 };
42
43
44 protected:
45 int m_numberOfPositionIterations;
46 int m_numberOfVelocityIterations;
47 // Simulation timescale
48 float m_timeScale;
49
50 public:
51 btSoftBodySolver() :
52 m_numberOfPositionIterations( 10 ),
53 m_timeScale( 1 )
54 {
55 m_numberOfVelocityIterations = 0;
56 m_numberOfPositionIterations = 5;
57 }
58
59 virtual ~btSoftBodySolver()
60 {
61 }
62
66 virtual SolverTypes getSolverType() const = 0;
67
68
70 virtual bool checkInitialized() = 0;
71
73 virtual void optimize( btAlignedObjectArray< btSoftBody * > &softBodies , bool forceUpdate=false) = 0;
74
76 virtual void copyBackToSoftBodies(bool bMove = true) = 0;
77
79 virtual void predictMotion( float solverdt ) = 0;
80
82 virtual void solveConstraints( float solverdt ) = 0;
83
85 virtual void updateSoftBodies() = 0;
86
88 virtual void processCollision( btSoftBody *, const struct btCollisionObjectWrapper* ) = 0;
89
91 virtual void processCollision( btSoftBody*, btSoftBody* ) = 0;
92
94 virtual void setNumberOfPositionIterations( int iterations )
95 {
96 m_numberOfPositionIterations = iterations;
97 }
98
100 virtual int getNumberOfPositionIterations()
101 {
102 return m_numberOfPositionIterations;
103 }
104
106 virtual void setNumberOfVelocityIterations( int iterations )
107 {
108 m_numberOfVelocityIterations = iterations;
109 }
110
112 virtual int getNumberOfVelocityIterations()
113 {
114 return m_numberOfVelocityIterations;
115 }
116
118 float getTimeScale()
119 {
120 return m_timeScale;
121 }
122
123 #if 0
124
127 virtual void addCollisionObjectForSoftBody( int clothIdentifier, btCollisionObject *collisionObject ) = 0;
128 #endif
129 };
130
135 class btSoftBodySolverOutput
136 {
137 protected:
138
139 public:
140 btSoftBodySolverOutput()
141 {
142 }
143
144 virtual ~btSoftBodySolverOutput()
145 {
146 }
147
148
150 virtual void copySoftBodyToVertexBuffer( const btSoftBody * const softBody, btVertexBufferDescriptor *vertexBuffer ) = 0;
151 };
152
153
154 #endif // #ifndef BT_SOFT_BODY_SOLVERS_H
btSoftBodySolver::getNumberOfVelocityIterations
virtual int getNumberOfVelocityIterations()
Get the number of velocity constraint solver iterations this solver uses.
Definition: btSoftBodySolvers.h:112
btSoftBodySolverOutput::btSoftBodySolverOutput
btSoftBodySolverOutput()
Definition: btSoftBodySolvers.h:140
btSoftBodySolver::checkInitialized
virtual bool checkInitialized()=0
Ensure that this solver is initialized.
btSoftBodySolver::setNumberOfPositionIterations
virtual void setNumberOfPositionIterations(int iterations)
Set the number of velocity constraint solver iterations this solver uses.
Definition: btSoftBodySolvers.h:94
btAlignedObjectArray< btSoftBody * >
btSoftBodySolver::CPU_SOLVER
Definition: btSoftBodySolvers.h:36
btSoftBodySolver::btSoftBodySolver
btSoftBodySolver()
Definition: btSoftBodySolvers.h:51
btSoftBodySolver::CL_SOLVER
Definition: btSoftBodySolvers.h:37
btSoftBodySolver::DX_SOLVER
Definition: btSoftBodySolvers.h:39
btTriangleIndexVertexArray.h
btSoftBodySolver::copyBackToSoftBodies
virtual void copyBackToSoftBodies(bool bMove=true)=0
Copy necessary data back to the original soft body source objects.
btSoftBodySolver::processCollision
virtual void processCollision(btSoftBody *, const struct btCollisionObjectWrapper *)=0
Process a collision between one of the world&#39;s soft bodies and another collision object.
btSoftBodySolver::optimize
virtual void optimize(btAlignedObjectArray< btSoftBody * > &softBodies, bool forceUpdate=false)=0
Optimize soft bodies in this solver.
btSoftBodySolver::SolverTypes
SolverTypes
Definition: btSoftBodySolvers.h:33
btSoftBodySolver::predictMotion
virtual void predictMotion(float solverdt)=0
Predict motion of soft bodies into next timestep.
btSoftBodySolver::solveConstraints
virtual void solveConstraints(float solverdt)=0
Solve constraints for a set of soft bodies.
btSoftBodySolver::getSolverType
virtual SolverTypes getSolverType() const =0
Return the type of the solver.
btSoftBodySolver::~btSoftBodySolver
virtual ~btSoftBodySolver()
Definition: btSoftBodySolvers.h:59
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:49
btSoftBodySolver::DX_SIMD_SOLVER
Definition: btSoftBodySolvers.h:40
btSoftBodySolver
Definition: btSoftBodySolvers.h:30
btSoftBodySolver::m_numberOfVelocityIterations
int m_numberOfVelocityIterations
Definition: btSoftBodySolvers.h:46
btSoftBodySolver::updateSoftBodies
virtual void updateSoftBodies()=0
Perform necessary per-step updates of soft bodies such as recomputing normals and bounding boxes...
btSoftBodySolver::DEFAULT_SOLVER
Definition: btSoftBodySolvers.h:35
btSoftBodySolverOutput
Class to manage movement of data from a solver to a given target.
Definition: btSoftBodySolvers.h:135
btSoftBodySolver::getTimeScale
float getTimeScale()
Return the timescale that the simulation is using.
Definition: btSoftBodySolvers.h:118
btSoftBodySolver::CL_SIMD_SOLVER
Definition: btSoftBodySolvers.h:38
btSoftBodySolverOutput::~btSoftBodySolverOutput
virtual ~btSoftBodySolverOutput()
Definition: btSoftBodySolvers.h:144
btSoftBody
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:71
btCollisionObjectWrapper
Definition: btCollisionObjectWrapper.h:17
btSoftBodySolver::setNumberOfVelocityIterations
virtual void setNumberOfVelocityIterations(int iterations)
Set the number of velocity constraint solver iterations this solver uses.
Definition: btSoftBodySolvers.h:106
btSoftBodySolver::getNumberOfPositionIterations
virtual int getNumberOfPositionIterations()
Get the number of velocity constraint solver iterations this solver uses.
Definition: btSoftBodySolvers.h:100
btSoftBodySolver::m_timeScale
float m_timeScale
Definition: btSoftBodySolvers.h:48
btSoftBodySolver::m_numberOfPositionIterations
int m_numberOfPositionIterations
Definition: btSoftBodySolvers.h:45
btVertexBufferDescriptor
Definition: btSoftBodySolverVertexBuffer.h:20