| 27 | constexpr float SELF_COLLISION_SPEED = 0.05f; // 1 == instantly separate circles. less means separation takes time |
| 28 | |
| 29 | struct DbVector2 { |
| 30 | float x; |
| 31 | float y; |
| 32 | |
| 33 | DbVector2() : x(0.0f), y(0.0f) {} |
| 34 | DbVector2(float x_in, float y_in) : x(x_in), y(y_in) {} |
| 35 | |
| 36 | float sqr_magnitude() const { |
| 37 | return x * x + y * y; |
| 38 | } |
| 39 | |
| 40 | float magnitude() const { |
| 41 | return std::sqrt(sqr_magnitude()); |
| 42 | } |
| 43 | |
| 44 | DbVector2 normalized() const { |
| 45 | float mag = magnitude(); |
| 46 | if (mag == 0.0f) { |
| 47 | return DbVector2(0.0f, 0.0f); |
| 48 | } |
| 49 | return DbVector2(x / mag, y / mag); |
| 50 | } |
| 51 | }; |
| 52 | SPACETIMEDB_STRUCT(DbVector2, x, y) |
| 53 | |
| 54 | inline DbVector2 operator+(const DbVector2& a, const DbVector2& b) { |
no outgoing calls
no test coverage detected
searching dependent graphs…