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

Bullet Collision Detection & Physics Library

btSoftBodySolvers.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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
21class btSoftBodyTriangleData;
22class btSoftBodyLinkData;
23class btSoftBodyVertexData;
24class btVertexBufferDescriptor;
25class btCollisionObject;
26class btSoftBody;
27
28 class btSoftBodySolver
29{
30public:
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 DEFORMABLE_SOLVER,
40 REDUCED_DEFORMABLE_SOLVER
41 };
42
43protected:
44 int m_numberOfPositionIterations;
45 int m_numberOfVelocityIterations;
46 // Simulation timescale
47 float m_timeScale;
48
49public:
50 btSoftBodySolver() : m_numberOfPositionIterations(10),
51 m_timeScale(1)
52 {
53 m_numberOfVelocityIterations = 0;
54 m_numberOfPositionIterations = 5;
55 }
56
57 virtual ~btSoftBodySolver()
58 {
59 }
60
64 virtual SolverTypes getSolverType() const = 0;
65
67 virtual bool checkInitialized() = 0;
68
70 virtual void optimize(btAlignedObjectArray<btSoftBody *> &softBodies, bool forceUpdate = false) = 0;
71
73 virtual void copyBackToSoftBodies(bool bMove = true) = 0;
74
76 virtual void predictMotion(btScalar solverdt) = 0;
77
79 virtual void solveConstraints(btScalar solverdt) = 0;
80
82 virtual void updateSoftBodies() = 0;
83
85 virtual void processCollision(btSoftBody *, const struct btCollisionObjectWrapper *) = 0;
86
88 virtual void processCollision(btSoftBody *, btSoftBody *) = 0;
89
91 virtual void setNumberOfPositionIterations(int iterations)
92 {
93 m_numberOfPositionIterations = iterations;
94 }
95
97 virtual int getNumberOfPositionIterations()
98 {
99 return m_numberOfPositionIterations;
100 }
101
103 virtual void setNumberOfVelocityIterations(int iterations)
104 {
105 m_numberOfVelocityIterations = iterations;
106 }
107
109 virtual int getNumberOfVelocityIterations()
110 {
111 return m_numberOfVelocityIterations;
112 }
113
115 float getTimeScale()
116 {
117 return m_timeScale;
118 }
119
120#if 0
124 virtual void addCollisionObjectForSoftBody( int clothIdentifier, btCollisionObject *collisionObject ) = 0;
125#endif
126};
127
132 class btSoftBodySolverOutput
133{
134protected:
135public:
136 btSoftBodySolverOutput()
137 {
138 }
139
140 virtual ~btSoftBodySolverOutput()
141 {
142 }
143
145 virtual void copySoftBodyToVertexBuffer(const btSoftBody *const softBody, btVertexBufferDescriptor *vertexBuffer) = 0;
146};
147
148#endif // #ifndef BT_SOFT_BODY_SOLVERS_H
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
btTriangleIndexVertexArray.h
btAlignedObjectArray< btSoftBody * >
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:51
btSoftBodySolverOutput
Class to manage movement of data from a solver to a given target.
Definition: btSoftBodySolvers.h:133
btSoftBodySolverOutput::btSoftBodySolverOutput
btSoftBodySolverOutput()
Definition: btSoftBodySolvers.h:136
btSoftBodySolverOutput::~btSoftBodySolverOutput
virtual ~btSoftBodySolverOutput()
Definition: btSoftBodySolvers.h:140
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
Definition: btSoftBodySolvers.h:29
btSoftBodySolver::processCollision
virtual void processCollision(btSoftBody *, btSoftBody *)=0
Process a collision between two soft bodies.
btSoftBodySolver::getNumberOfVelocityIterations
virtual int getNumberOfVelocityIterations()
Get the number of velocity constraint solver iterations this solver uses.
Definition: btSoftBodySolvers.h:109
btSoftBodySolver::predictMotion
virtual void predictMotion(btScalar solverdt)=0
Predict motion of soft bodies into next timestep.
btSoftBodySolver::m_timeScale
float m_timeScale
Definition: btSoftBodySolvers.h:47
btSoftBodySolver::setNumberOfVelocityIterations
virtual void setNumberOfVelocityIterations(int iterations)
Set the number of velocity constraint solver iterations this solver uses.
Definition: btSoftBodySolvers.h:103
btSoftBodySolver::getTimeScale
float getTimeScale()
Return the timescale that the simulation is using.
Definition: btSoftBodySolvers.h:115
btSoftBodySolver::processCollision
virtual void processCollision(btSoftBody *, const struct btCollisionObjectWrapper *)=0
Process a collision between one of the world's soft bodies and another collision object.
btSoftBodySolver::setNumberOfPositionIterations
virtual void setNumberOfPositionIterations(int iterations)
Set the number of velocity constraint solver iterations this solver uses.
Definition: btSoftBodySolvers.h:91
btSoftBodySolver::getNumberOfPositionIterations
virtual int getNumberOfPositionIterations()
Get the number of velocity constraint solver iterations this solver uses.
Definition: btSoftBodySolvers.h:97
btSoftBodySolver::btSoftBodySolver
btSoftBodySolver()
Definition: btSoftBodySolvers.h:50
btSoftBodySolver::getSolverType
virtual SolverTypes getSolverType() const =0
Return the type of the solver.
btSoftBodySolver::m_numberOfPositionIterations
int m_numberOfPositionIterations
Definition: btSoftBodySolvers.h:44
btSoftBodySolver::checkInitialized
virtual bool checkInitialized()=0
Ensure that this solver is initialized.
btSoftBodySolver::m_numberOfVelocityIterations
int m_numberOfVelocityIterations
Definition: btSoftBodySolvers.h:45
btSoftBodySolver::copyBackToSoftBodies
virtual void copyBackToSoftBodies(bool bMove=true)=0
Copy necessary data back to the original soft body source objects.
btSoftBodySolver::~btSoftBodySolver
virtual ~btSoftBodySolver()
Definition: btSoftBodySolvers.h:57
btSoftBodySolver::updateSoftBodies
virtual void updateSoftBodies()=0
Perform necessary per-step updates of soft bodies such as recomputing normals and bounding boxes.
btSoftBodySolver::SolverTypes
SolverTypes
Definition: btSoftBodySolvers.h:32
btSoftBodySolver::CL_SIMD_SOLVER
@ CL_SIMD_SOLVER
Definition: btSoftBodySolvers.h:36
btSoftBodySolver::DEFAULT_SOLVER
@ DEFAULT_SOLVER
Definition: btSoftBodySolvers.h:33
btSoftBodySolver::DX_SIMD_SOLVER
@ DX_SIMD_SOLVER
Definition: btSoftBodySolvers.h:38
btSoftBodySolver::DX_SOLVER
@ DX_SOLVER
Definition: btSoftBodySolvers.h:37
btSoftBodySolver::CPU_SOLVER
@ CPU_SOLVER
Definition: btSoftBodySolvers.h:34
btSoftBodySolver::DEFORMABLE_SOLVER
@ DEFORMABLE_SOLVER
Definition: btSoftBodySolvers.h:39
btSoftBodySolver::REDUCED_DEFORMABLE_SOLVER
@ REDUCED_DEFORMABLE_SOLVER
Definition: btSoftBodySolvers.h:40
btSoftBodySolver::CL_SOLVER
@ CL_SOLVER
Definition: btSoftBodySolvers.h:35
btSoftBodySolver::solveConstraints
virtual void solveConstraints(btScalar solverdt)=0
Solve constraints for a set of soft bodies.
btSoftBodySolver::optimize
virtual void optimize(btAlignedObjectArray< btSoftBody * > &softBodies, bool forceUpdate=false)=0
Optimize soft bodies in this solver.
btSoftBody
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:75
btVertexBufferDescriptor
Definition: btSoftBodySolverVertexBuffer.h:20
btCollisionObjectWrapper
Definition: btCollisionObjectWrapper.h:18