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 class btSoftBodyTriangleData;
22 class btSoftBodyLinkData;
23 class btSoftBodyVertexData;
24 class btVertexBufferDescriptor;
25 class btCollisionObject;
26 class btSoftBody;
27
28 class btSoftBodySolver
29 {
30 public:
31 enum SolverTypes
32 {
33 DEFAULT_SOLVER,
34 CPU_SOLVER,
35 CL_SOLVER,
36 CL_SIMD_SOLVER,
37 DX_SOLVER,
38 DX_SIMD_SOLVER
39 };
40
41 protected:
42 int m_numberOfPositionIterations;
43 int m_numberOfVelocityIterations;
44 // Simulation timescale
45 float m_timeScale;
46
47 public:
48 btSoftBodySolver() : m_numberOfPositionIterations(10),
49 m_timeScale(1)
50 {
51 m_numberOfVelocityIterations = 0;
52 m_numberOfPositionIterations = 5;
53 }
54
55 virtual ~btSoftBodySolver()
56 {
57 }
58
62 virtual SolverTypes getSolverType() const = 0;
63
65 virtual bool checkInitialized() = 0;
66
68 virtual void optimize(btAlignedObjectArray<btSoftBody *> &softBodies, bool forceUpdate = false) = 0;
69
71 virtual void copyBackToSoftBodies(bool bMove = true) = 0;
72
74 virtual void predictMotion(float solverdt) = 0;
75
77 virtual void solveConstraints(float solverdt) = 0;
78
80 virtual void updateSoftBodies() = 0;
81
83 virtual void processCollision(btSoftBody *, const struct btCollisionObjectWrapper *) = 0;
84
86 virtual void processCollision(btSoftBody *, btSoftBody *) = 0;
87
89 virtual void setNumberOfPositionIterations(int iterations)
90 {
91 m_numberOfPositionIterations = iterations;
92 }
93
95 virtual int getNumberOfPositionIterations()
96 {
97 return m_numberOfPositionIterations;
98 }
99
101 virtual void setNumberOfVelocityIterations(int iterations)
102 {
103 m_numberOfVelocityIterations = iterations;
104 }
105
107 virtual int getNumberOfVelocityIterations()
108 {
109 return m_numberOfVelocityIterations;
110 }
111
113 float getTimeScale()
114 {
115 return m_timeScale;
116 }
117
118 #if 0
119
122 virtual void addCollisionObjectForSoftBody( int clothIdentifier, btCollisionObject *collisionObject ) = 0;
123 #endif
124 };
125
130 class btSoftBodySolverOutput
131 {
132 protected:
133 public:
134 btSoftBodySolverOutput()
135 {
136 }
137
138 virtual ~btSoftBodySolverOutput()
139 {
140 }
141
143 virtual void copySoftBodyToVertexBuffer(const btSoftBody *const softBody, btVertexBufferDescriptor *vertexBuffer) = 0;
144 };
145
146 #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:107
btSoftBodySolverOutput::btSoftBodySolverOutput
btSoftBodySolverOutput()
Definition: btSoftBodySolvers.h:134
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:89
btAlignedObjectArray
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
Definition: btAlignedObjectArray.h:52
btSoftBodySolver::CPU_SOLVER
Definition: btSoftBodySolvers.h:34
btSoftBodySolver::btSoftBodySolver
btSoftBodySolver()
Definition: btSoftBodySolvers.h:48
btSoftBodySolver::CL_SOLVER
Definition: btSoftBodySolvers.h:35
btSoftBodySolver::DX_SOLVER
Definition: btSoftBodySolvers.h:37
btTriangleIndexVertexArray.h
btSoftBodySolverOutput::copySoftBodyToVertexBuffer
virtual void copySoftBodyToVertexBuffer(const btSoftBody *const softBody, btVertexBufferDescriptor *vertexBuffer)=0
Output current computed vertex data to the vertex buffers for all cloths in the solver.
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::SolverTypes
SolverTypes
Definition: btSoftBodySolvers.h:31
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:55
btSoftBodySolver::optimize
virtual void optimize(btAlignedObjectArray< btSoftBody *> &softBodies, bool forceUpdate=false)=0
Optimize soft bodies in this solver.
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:48
btSoftBodySolver::DX_SIMD_SOLVER
Definition: btSoftBodySolvers.h:38
btSoftBodySolver
Definition: btSoftBodySolvers.h:28
btSoftBodySolver::m_numberOfVelocityIterations
int m_numberOfVelocityIterations
Definition: btSoftBodySolvers.h:43
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:33
btSoftBodySolverOutput
Class to manage movement of data from a solver to a given target.
Definition: btSoftBodySolvers.h:130
btSoftBodySolver::getTimeScale
float getTimeScale()
Return the timescale that the simulation is using.
Definition: btSoftBodySolvers.h:113
btSoftBodySolver::CL_SIMD_SOLVER
Definition: btSoftBodySolvers.h:36
btSoftBodySolverOutput::~btSoftBodySolverOutput
virtual ~btSoftBodySolverOutput()
Definition: btSoftBodySolvers.h:138
btSoftBody
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:70
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:101
btSoftBodySolver::getNumberOfPositionIterations
virtual int getNumberOfPositionIterations()
Get the number of velocity constraint solver iterations this solver uses.
Definition: btSoftBodySolvers.h:95
btSoftBodySolver::m_timeScale
float m_timeScale
Definition: btSoftBodySolvers.h:45
btSoftBodySolver::m_numberOfPositionIterations
int m_numberOfPositionIterations
Definition: btSoftBodySolvers.h:42
btVertexBufferDescriptor
Definition: btSoftBodySolverVertexBuffer.h:19