]> git.localhorst.tv Git - gong.git/blobdiff - src/physics/State.hpp
simple physics simulation
[gong.git] / src / physics / State.hpp
diff --git a/src/physics/State.hpp b/src/physics/State.hpp
new file mode 100644 (file)
index 0000000..76ff16c
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef GONG_PHYSICS_STATE_HPP_
+#define GONG_PHYSICS_STATE_HPP_
+
+#include "../graphics/glm.hpp"
+
+#include <glm/gtc/quaternion.hpp>
+
+
+namespace gong {
+namespace physics {
+
+struct State {
+       /// position of center of mass
+       glm::vec3 pos;
+       /// linear momentum
+       glm::vec3 lin;
+       /// orientation
+       glm::quat orient;
+       /// angular momentum
+       glm::vec3 ang;
+       /// angular velocity as quat
+       glm::quat Spin() const noexcept {
+               return 0.5f * glm::quat(0.0f, ang * inverse_inertia) * orient;
+       }
+       float mass;
+       /// 1/mass
+       float inverse_mass;
+       /// rotational inertia
+       float inertia;
+       /// 1/inertia
+       float inverse_inertia;
+};
+
+}
+}
+
+#endif