MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / DbVector2

Class DbVector2

demo/Blackholio/server-cpp/spacetimedb/src/lib.cpp:29–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27constexpr float SELF_COLLISION_SPEED = 0.05f; // 1 == instantly separate circles. less means separation takes time
28
29struct 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};
52SPACETIMEDB_STRUCT(DbVector2, x, y)
53
54inline DbVector2 operator+(const DbVector2& a, const DbVector2& b) {

Callers 9

normalizedMethod · 0.70
operator+Function · 0.70
operator-Function · 0.70
operator*Function · 0.70
operator/Function · 0.70
spawn_circle_atFunction · 0.70
calculate_center_of_massFunction · 0.70
SPACETIMEDB_REDUCERFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…