2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
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:
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.
16 #ifndef BT_CONTACT_SOLVER_INFO
17 #define BT_CONTACT_SOLVER_INFO
19 #include "LinearMath/btScalar.h"
23 SOLVER_RANDMIZE_ORDER = 1,
24 SOLVER_FRICTION_SEPARATE = 2,
25 SOLVER_USE_WARMSTARTING = 4,
26 SOLVER_USE_2_FRICTION_DIRECTIONS = 16,
27 SOLVER_ENABLE_FRICTION_DIRECTION_CACHING = 32,
28 SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION = 64,
29 SOLVER_CACHE_FRIENDLY = 128,
31 SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS = 512,
32 SOLVER_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS = 1024,
33 SOLVER_DISABLE_IMPLICIT_CONE_FRICTION = 2048,
34 SOLVER_USE_ARTICULATED_WARMSTARTING = 4096,
37 struct btContactSolverInfoData
40 btScalar m_damping; //global non-contact constraint damping, can be locally overridden by constraints during 'getInfo2'.
43 btScalar m_restitution;
45 btScalar m_maxErrorReduction;
46 btScalar m_sor; //successive over-relaxation term
47 btScalar m_erp; //error reduction for non-contact constraints
48 btScalar m_erp2; //error reduction for contact constraints
49 btScalar m_deformable_erp; //error reduction for deformable constraints
50 btScalar m_deformable_cfm; //constraint force mixing for deformable constraints
51 btScalar m_deformable_maxErrorReduction; // maxErrorReduction for deformable contact
52 btScalar m_globalCfm; //constraint force mixing for contacts and non-contacts
53 btScalar m_frictionERP; //error reduction for friction constraints
54 btScalar m_frictionCFM; //constraint force mixing for friction constraints
57 btScalar m_splitImpulsePenetrationThreshold;
58 btScalar m_splitImpulseTurnErp;
59 btScalar m_linearSlop;
60 btScalar m_warmstartingFactor;
61 btScalar m_articulatedWarmstartingFactor;
63 int m_restingContactRestitutionThreshold;
64 int m_minimumSolverBatchSize;
65 btScalar m_maxGyroscopicForce;
66 btScalar m_singleAxisRollingFrictionThreshold;
67 btScalar m_leastSquaresResidualThreshold;
68 btScalar m_restitutionVelocityThreshold;
69 bool m_jointFeedbackInWorldSpace;
70 bool m_jointFeedbackInJointFrame;
71 int m_reportSolverAnalytics;
72 int m_numNonContactInnerIterations;
75 struct btContactSolverInfo : public btContactSolverInfoData
77 inline btContactSolverInfo()
79 m_tau = btScalar(0.6);
80 m_damping = btScalar(1.0);
81 m_friction = btScalar(0.3);
82 m_timeStep = btScalar(1.f / 60.f);
83 m_restitution = btScalar(0.);
84 m_maxErrorReduction = btScalar(20.);
86 m_erp = btScalar(0.2);
87 m_erp2 = btScalar(0.2);
88 m_deformable_erp = btScalar(0.06);
89 m_deformable_cfm = btScalar(0.01);
90 m_deformable_maxErrorReduction = btScalar(0.1);
91 m_globalCfm = btScalar(0.);
92 m_frictionERP = btScalar(0.2); //positional friction 'anchors' are disabled by default
93 m_frictionCFM = btScalar(0.);
95 m_splitImpulse = true;
96 m_splitImpulsePenetrationThreshold = -.04f;
97 m_splitImpulseTurnErp = 0.1f;
98 m_linearSlop = btScalar(0.0);
99 m_warmstartingFactor = btScalar(0.85);
100 m_articulatedWarmstartingFactor = btScalar(0.85);
101 //m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD | SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION|SOLVER_USE_2_FRICTION_DIRECTIONS|SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;// | SOLVER_RANDMIZE_ORDER;
102 m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD; // | SOLVER_RANDMIZE_ORDER;
103 m_restingContactRestitutionThreshold = 2; //unused as of 2.81
104 m_minimumSolverBatchSize = 128; //try to combine islands until the amount of constraints reaches this limit
105 m_maxGyroscopicForce = 100.f; ///it is only used for 'explicit' version of gyroscopic force
106 m_singleAxisRollingFrictionThreshold = 1e30f; ///if the velocity is above this threshold, it will use a single constraint row (axis), otherwise 3 rows.
107 m_leastSquaresResidualThreshold = 0.f;
108 m_restitutionVelocityThreshold = 0.2f; //if the relative velocity is below this threshold, there is zero restitution
109 m_jointFeedbackInWorldSpace = false;
110 m_jointFeedbackInJointFrame = false;
111 m_reportSolverAnalytics = 0;
112 m_numNonContactInnerIterations = 1; // the number of inner iterations for solving motor constraint in a single iteration of the constraint solve
116 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
117 struct btContactSolverInfoDoubleData
120 double m_damping; //global non-contact constraint damping, can be locally overridden by constraints during 'getInfo2'.
123 double m_restitution;
124 double m_maxErrorReduction;
126 double m_erp; //used as Baumgarte factor
127 double m_erp2; //used in Split Impulse
128 double m_globalCfm; //constraint force mixing
129 double m_splitImpulsePenetrationThreshold;
130 double m_splitImpulseTurnErp;
132 double m_warmstartingFactor;
133 double m_articulatedWarmstartingFactor;
134 double m_maxGyroscopicForce; ///it is only used for 'explicit' version of gyroscopic force
135 double m_singleAxisRollingFrictionThreshold;
139 int m_restingContactRestitutionThreshold;
140 int m_minimumSolverBatchSize;
144 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
145 struct btContactSolverInfoFloatData
148 float m_damping; //global non-contact constraint damping, can be locally overridden by constraints during 'getInfo2'.
153 float m_maxErrorReduction;
155 float m_erp; //used as Baumgarte factor
157 float m_erp2; //used in Split Impulse
158 float m_globalCfm; //constraint force mixing
159 float m_splitImpulsePenetrationThreshold;
160 float m_splitImpulseTurnErp;
163 float m_warmstartingFactor;
164 float m_articulatedWarmstartingFactor;
165 float m_maxGyroscopicForce;
167 float m_singleAxisRollingFrictionThreshold;
170 int m_restingContactRestitutionThreshold;
172 int m_minimumSolverBatchSize;
177 #endif //BT_CONTACT_SOLVER_INFO