Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-10-17 17:19:03 +0000
committerStijn Buys <ingar@osirion.org>2010-10-17 17:19:03 +0000
commitd6e4c4e7c2b1e28961f1dfe2f25ef96ced60b21b (patch)
tree63744dff093a8b23f65d9c68b922b678805647d9 /src/math
parentea6e6bb769d713ac55114c1940626f13e384ebed (diff)
core bullet physics support,
initial vstrafe support
Diffstat (limited to 'src/math')
-rw-r--r--src/math/axis.cc9
-rw-r--r--src/math/axis.h12
-rw-r--r--src/math/vector3f.cc7
-rw-r--r--src/math/vector3f.h11
4 files changed, 38 insertions, 1 deletions
diff --git a/src/math/axis.cc b/src/math/axis.cc
index 8273469..7281047 100644
--- a/src/math/axis.cc
+++ b/src/math/axis.cc
@@ -35,6 +35,15 @@ void Axis::assign(const Axis & other)
}
}
+void Axis::assign(const btMatrix3x3 & other)
+{
+ for (size_t i = 0; i < 3; i++) {
+ for (size_t j = 0; j < 3; j++) {
+ axis_vector[i][j] = other[i][j];
+ }
+ }
+}
+
Axis & Axis::operator=(const Axis & other)
{
assign(other);
diff --git a/src/math/axis.h b/src/math/axis.h
index c22568c..d3a5ec6 100644
--- a/src/math/axis.h
+++ b/src/math/axis.h
@@ -10,7 +10,7 @@
#include <iostream>
#include "math/vector3f.h"
-
+#include "LinearMath/btMatrix3x3.h"
namespace math
{
@@ -24,6 +24,8 @@ public:
void clear();
void assign(const Axis & other);
+
+ void assign(const btMatrix3x3 & other);
/// global coordinates of the X-axis in the local coordinates system
inline const Vector3f & forward() const {
@@ -86,6 +88,14 @@ private:
Vector3f axis_vector[3];
};
+/// helper function to conver math::Axis to btMatrix3x3
+inline btMatrix3x3 to_btMatrix3x3(const math::Axis &a)
+{
+ return btMatrix3x3(a[0][0], a[0][1], a[0][2],
+ a[1][0], a[1][1], a[1][2],
+ a[2][0], a[2][1], a[2][2]);
+}
+
/// write an axis to a std::ostream
std::ostream &operator<<(std::ostream & os, const Axis & axis);
diff --git a/src/math/vector3f.cc b/src/math/vector3f.cc
index 4594665..421d84e 100644
--- a/src/math/vector3f.cc
+++ b/src/math/vector3f.cc
@@ -48,6 +48,13 @@ void Vector3f::assign(const Vector3f & other)
memcpy(coord, other.coord, sizeof(coord));
}
+void Vector3f::assign(const btVector3 & other)
+{
+ for (size_t i = 0; i < 3; i++) {
+ coord[i] = other[i];
+ }
+}
+
Vector3f & Vector3f::operator=(const Vector3f & other)
{
assign(other);
diff --git a/src/math/vector3f.h b/src/math/vector3f.h
index 09e6e84..a7437aa 100644
--- a/src/math/vector3f.h
+++ b/src/math/vector3f.h
@@ -10,6 +10,8 @@
#include <iostream>
#include "math/vector3f.h"
+#include "LinearMath/btVector3.h"
+
namespace math
{
@@ -49,6 +51,9 @@ public:
/// assignment
void assign(const Vector3f & other);
+
+ /// assign bullet btVector3 value
+ void assign(const btVector3 & other);
/// assignment operator
Vector3f& operator=(const Vector3f &other);
@@ -214,6 +219,12 @@ float distance(const Vector3f& first, const Vector3f& second);
/// distance between two vectors squared
float distancesquared(const Vector3f& first, const Vector3f& second);
+/// helper function to convert Vector3f to btVector3
+inline btVector3 to_btVector3(const math::Vector3f & v)
+{
+ return btVector3(v[0], v[1], v[2]);
+}
+
} // namespace math
#endif // __INCLUDED_MATH_VECTOR3F_H__