|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "../extras/Utils.h" |
| 4 | +#include "../math/Bounds4.h" |
| 5 | +#include "../math/math.h" |
| 6 | +#include "../math/Matrix4.h" |
| 7 | +#include "../math/Plane4.h" |
| 8 | +#include "../math/Ray4.h" |
| 9 | +#include "../math/Transform4.h" |
| 10 | +#include "../math/Vector4.h" |
| 11 | +#include "../math/Tensor4.h" |
| 12 | +#include <vector> |
| 13 | +#include <stack> |
| 14 | +#include <map> |
| 15 | +#include <algorithm> |
| 16 | + |
| 17 | +namespace Forth |
| 18 | +{ |
| 19 | + namespace Physics |
| 20 | + { |
| 21 | + /// Common constant for physics simulation |
| 22 | + struct Common |
| 23 | + { |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// Default gravity for all simulations. |
| 27 | + /// This parameter can be dynamically adjusted. |
| 28 | + /// </summary> |
| 29 | + static Vector4 GRAVITY; |
| 30 | + |
| 31 | + /// <summary> |
| 32 | + /// Simulation range helps to avoid wasted time computation of computing |
| 33 | + /// Objects that out of range (e.g. object keeps falling down). |
| 34 | + /// The object is deactivated once becomes so. |
| 35 | + /// </summary> |
| 36 | + static Bounds4 SIM_RANGE; |
| 37 | + |
| 38 | + /// <summary> |
| 39 | + /// Constant collision solving iteration. |
| 40 | + /// Higher values are more realistic, yet more expensive. |
| 41 | + /// Default is 15, can be put between 5 to 20 |
| 42 | + /// </summary> |
| 43 | + static int ITERATIONS; |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// Enables or disables rigid body sleeping. |
| 47 | + /// It's an important optimization on every physics engine. |
| 48 | + /// It's recommended to leave this on. |
| 49 | + /// </summary> |
| 50 | + static bool ALLOW_SLEEP; |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// When two objects lay on each other should the simulator simulate friction? |
| 54 | + /// It's recommended to leave this on. |
| 55 | + /// </summary> |
| 56 | + static bool ENABLE_FRICTION; |
| 57 | + |
| 58 | + /// <summary> |
| 59 | + /// Constant maximum multi contact count. Don't change. |
| 60 | + /// </summary> |
| 61 | + const static int MULTICONTACT_COUNT = 16; |
| 62 | + |
| 63 | + /// <summary> |
| 64 | + /// Maximum allowed linear velocity that makes a rigidbody sleeps (Default is 0.01) |
| 65 | + /// </summary> |
| 66 | + static float SLEEP_LINEAR; |
| 67 | + |
| 68 | + /// <summary> |
| 69 | + /// Maximum allowed angular velocity that makes a rigidbody sleeps (Default is 2 deg) |
| 70 | + /// </summary> |
| 71 | + static float SLEEP_ANGULAR; |
| 72 | + |
| 73 | + /// <summary> |
| 74 | + /// Simulator don't make rigidbody sleeps instantly. |
| 75 | + /// They have a chance by given time to awake by itself. (Default is 0.5) |
| 76 | + /// </summary> |
| 77 | + static float SLEEP_TIME; |
| 78 | + |
| 79 | + /// <summary> |
| 80 | + /// How fast the collision must be resolved? (Default is 0.2) |
| 81 | + /// </summary> |
| 82 | + static float BAUMGARTE; |
| 83 | + |
| 84 | + /// <summary> |
| 85 | + /// Offset of allowed contact depth before kicked out by the solver. |
| 86 | + /// Allow very small number to avoid jitter. (Default is 0.05) |
| 87 | + /// </summary> |
| 88 | + static float PENETRATION_SLOP; |
| 89 | + |
| 90 | + /// <summary> |
| 91 | + /// Maximum allowed delta time. This prevents objects bypassing |
| 92 | + /// each other because of too large delta time. (Default is 0.02) |
| 93 | + /// </summary> |
| 94 | + static float MAX_DT; |
| 95 | + |
| 96 | + typedef float(*ShapeMixCB)(class Shape*, class Shape*); |
| 97 | + |
| 98 | + static ShapeMixCB MixRestitution; |
| 99 | + static ShapeMixCB MixFriction; |
| 100 | + |
| 101 | + /// <summary> |
| 102 | + /// Restitution (bounce) mixing. Default is max |
| 103 | + /// </summary> |
| 104 | + static float DefMixRestitution(class Shape* A, class Shape* B); |
| 105 | + |
| 106 | + /// <summary> |
| 107 | + /// Friction (slide) mixing. Default is average |
| 108 | + /// </summary> |
| 109 | + static float DefMixFriction(class Shape* A, class Shape* B); |
| 110 | + }; |
| 111 | + } // namespace Physics |
| 112 | +} // namespace Forth |
0 commit comments