]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
refactored vector classes to avoid reinterpret_cast
authorspog <spog>
Tue, 9 May 2006 22:07:29 +0000 (22:07 +0000)
committerspog <spog>
Tue, 9 May 2006 22:07:29 +0000 (22:07 +0000)
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@60 8a3a26a2-13c4-0310-b231-cf6edde360e5

21 files changed:
include/ibrush.h
include/iglrender.h
include/ipatch.h
include/irender.h
include/qerplugin.h
include/selectable.h
libs/generic/vector.cpp [new file with mode: 0644]
libs/generic/vector.h [new file with mode: 0644]
libs/libs.vcproj
libs/math/aabb.h
libs/math/vector.h
libs/render.h
libs/stringio.h
libs/texturelib.h
plugins/entity/targetable.h
plugins/md3model/md5.cpp
radiant/brush_primit.cpp
radiant/patch.cpp
radiant/patch.h
radiant/selection.cpp
radiant/view.h

index f7a58f5597a5ba15b416d168b87f713f9344658c..8aaf4b7dce9cdcc4f129d3247b743aae4d58ce64 100644 (file)
@@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "generic/constant.h"
 #include "generic/callback.h"
 
 #include "generic/constant.h"
 #include "generic/callback.h"
-#include "math/vector.h"
+#include "generic/vector.h"
 #include "itexdef.h"
 
 namespace scene
 #include "itexdef.h"
 
 namespace scene
index d5b3684a214f604c28e74ee30e90753ac6eac061..762160266dee0e1efec2ca9962a50e41e93bce9e 100644 (file)
@@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_IGLRENDER_H
 
 #include "igl.h"
 #define INCLUDED_IGLRENDER_H
 
 #include "igl.h"
-#include "math/vector.h"
+#include "generic/vector.h"
 class AABB;
 class Matrix4;
 
 class AABB;
 class Matrix4;
 
index eee123e40864c122dc289a3f475185fe3e4436a6..48ce39b5b640a4aab5c15a660a4f4810d5918381 100644 (file)
@@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_IPATCH_H
 
 #include "generic/constant.h"
 #define INCLUDED_IPATCH_H
 
 #include "generic/constant.h"
-#include "math/vector.h"
+#include "generic/vector.h"
 
 namespace scene
 {
 
 namespace scene
 {
index 2846670870fa1366fa9c975fed3d27c01aecc00a..d9c40b6f41a72155e1339beff1d3f806043898a2 100644 (file)
@@ -116,7 +116,7 @@ class Matrix4;
 struct qtexture_t;
 class ModuleObserver;
 
 struct qtexture_t;
 class ModuleObserver;
 
-#include "math/vector.h"
+#include "generic/vector.h"
 
 class Shader
 {
 
 class Shader
 {
index 861593f6c384c7aa77b4a184116fd2a1dca9cf12..7f2f9ca279743c207e345491530b83ec700123bc 100644 (file)
@@ -99,7 +99,7 @@ class ModuleObserver;
 
 #include "signal/signalfwd.h"
 #include "windowobserver.h"
 
 #include "signal/signalfwd.h"
 #include "windowobserver.h"
-#include "math/vector.h"
+#include "generic/vector.h"
 
 typedef SignalHandler3<const WindowVector&, ButtonIdentifier, ModifierFlags> MouseEventHandler;
 typedef SignalFwd<MouseEventHandler>::handler_id_type MouseEventHandlerId;
 
 typedef SignalHandler3<const WindowVector&, ButtonIdentifier, ModifierFlags> MouseEventHandler;
 typedef SignalFwd<MouseEventHandler>::handler_id_type MouseEventHandlerId;
index 774f4e0b46df59f9e92bbf4a35af969fb118158f..fffcfe2977906c067ec363b06dd8798cfc2a94e4 100644 (file)
@@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <cstddef>
 
 
 #include <cstddef>
 
-#include "math/vector.h"
+#include "generic/vector.h"
 #include "scenelib.h"
 #include "generic/callbackfwd.h"
 
 #include "scenelib.h"
 #include "generic/callbackfwd.h"
 
diff --git a/libs/generic/vector.cpp b/libs/generic/vector.cpp
new file mode 100644 (file)
index 0000000..83765dc
--- /dev/null
@@ -0,0 +1,3 @@
+
+#include "vector.h"
+
diff --git a/libs/generic/vector.h b/libs/generic/vector.h
new file mode 100644 (file)
index 0000000..6e6f74e
--- /dev/null
@@ -0,0 +1,259 @@
+
+#if !defined(INCLUDED_VECTOR_H)
+#define INCLUDED_VECTOR_H
+
+#include <cstddef>
+
+template <typename Element>
+class BasicVector2
+{
+  Element m_elements[2];
+public:
+  BasicVector2()
+  {
+  }
+  BasicVector2(const Element& x_, const Element& y_)
+  {
+    x() = x_;
+    y() = y_;
+  }
+
+  Element& x()
+  {
+    return m_elements[0];
+  }
+  const Element& x() const
+  {
+    return m_elements[0];
+  }
+  Element& y()
+  {
+    return m_elements[1];
+  }
+  const Element& y() const
+  {
+    return m_elements[1];
+  }
+
+  const Element& operator[](std::size_t i) const
+  {
+    return m_elements[i];
+  }
+  Element& operator[](std::size_t i)
+  {
+    return m_elements[i];
+  }
+
+  Element* data()
+  {
+    return m_elements;
+  }
+  const Element* data() const
+  {
+    return m_elements;
+  }
+};
+
+/// \brief A 3-element vector.
+template<typename Element>
+class BasicVector3
+{
+  Element m_elements[3];
+public:
+
+  BasicVector3()
+  {
+  }
+  template<typename OtherElement>
+  BasicVector3(const BasicVector3<OtherElement>& other)
+  {
+    x() = static_cast<Element>(other.x());
+    y() = static_cast<Element>(other.y());
+    z() = static_cast<Element>(other.z());
+  }
+  BasicVector3(const Element& x_, const Element& y_, const Element& z_)
+  {
+    x() = x_;
+    y() = y_;
+    z() = z_;
+  }
+
+  Element& x()
+  {
+    return m_elements[0];
+  }
+  const Element& x() const
+  {
+    return m_elements[0];
+  }
+  Element& y()
+  {
+    return m_elements[1];
+  }
+  const Element& y() const
+  {
+    return m_elements[1];
+  }
+  Element& z()
+  {
+    return m_elements[2];
+  }
+  const Element& z() const
+  {
+    return m_elements[2];
+  }
+
+  const Element& operator[](std::size_t i) const
+  {
+    return m_elements[i];
+  }
+  Element& operator[](std::size_t i)
+  {
+    return m_elements[i];
+  }
+
+  Element* data()
+  {
+    return m_elements;
+  }
+  const Element* data() const
+  {
+    return m_elements;
+  }
+};
+
+/// \brief A 4-element vector.
+template<typename Element>
+class BasicVector4
+{
+  Element m_elements[4];
+public:
+
+  BasicVector4()
+  {
+  }
+  BasicVector4(Element x_, Element y_, Element z_, Element w_)
+  {
+    x() = x_;
+    y() = y_;
+    z() = z_;
+    w() = w_;
+  }
+  BasicVector4(const BasicVector3<Element>& self, Element w_)
+  {
+    x() = self.x();
+    y() = self.y();
+    z() = self.z();
+    w() = w_;
+  }
+
+  Element& x()
+  {
+    return m_elements[0];
+  }
+  const Element& x() const
+  {
+    return m_elements[0];
+  }
+  Element& y()
+  {
+    return m_elements[1];
+  }
+  const Element& y() const
+  {
+    return m_elements[1];
+  }
+  Element& z()
+  {
+    return m_elements[2];
+  }
+  const Element& z() const
+  {
+    return m_elements[2];
+  }
+  Element& w()
+  {
+    return m_elements[3];
+  }
+  const Element& w() const
+  {
+    return m_elements[3];
+  }
+
+  Element index(std::size_t i) const
+  {
+    return m_elements[i];
+  }
+  Element& index(std::size_t i)
+  {
+    return m_elements[i];
+  }
+  Element operator[](std::size_t i) const
+  {
+    return m_elements[i];
+  }
+  Element& operator[](std::size_t i)
+  {
+    return m_elements[i];
+  }
+
+  Element* data()
+  {
+    return m_elements;
+  }
+  const Element* data() const
+  {
+    return m_elements;
+  }
+};
+
+template<typename Element>
+inline BasicVector3<Element> vector3_from_array(const Element* array)
+{
+  return BasicVector3<Element>(array[0], array[1], array[2]);
+}
+
+template<typename Element>
+inline Element* vector3_to_array(BasicVector3<Element>& self)
+{
+  return self.data();
+}
+template<typename Element>
+inline const Element* vector3_to_array(const BasicVector3<Element>& self)
+{
+  return self.data();
+}
+
+template<typename Element>
+inline Element* vector4_to_array(BasicVector4<Element>& self)
+{
+  return self.data();
+}
+template<typename Element>
+inline const Element* vector4_to_array(const BasicVector4<Element>& self)
+{
+  return self.data();
+}
+
+template<typename Element>
+inline BasicVector3<Element>& vector4_to_vector3(BasicVector4<Element>& self)
+{
+  return *reinterpret_cast<BasicVector3<Element>*>(vector4_to_array(self));
+}
+template<typename Element>
+inline const BasicVector3<Element>& vector4_to_vector3(const BasicVector4<Element>& self)
+{
+  return *reinterpret_cast<const BasicVector3<Element>*>(vector4_to_array(self));
+}
+
+/// \brief A 2-element vector stored in single-precision floating-point.
+typedef BasicVector2<float> Vector2;
+
+/// \brief A 3-element vector stored in single-precision floating-point.
+typedef BasicVector3<float> Vector3;
+
+/// \brief A 4-element vector stored in single-precision floating-point.
+typedef BasicVector4<float> Vector4;
+
+
+#endif
index 00bd4e06adef31da311ceda87e8b6b011362022d..2894ed08e38c7290142ce0fec5b551ed4ae61fe2 100644 (file)
                        <File
                                RelativePath=".\generic\static.h">
                        </File>
                        <File
                                RelativePath=".\generic\static.h">
                        </File>
+                       <File
+                               RelativePath=".\generic\vector.cpp">
+                               <FileConfiguration
+                                       Name="Debug|Win32">
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32">
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath=".\generic\vector.h">
+                       </File>
                </Filter>
                <Filter
                        Name="memory"
                </Filter>
                <Filter
                        Name="memory"
index a2476e456eae42b8c77df13cbfd2315924a06592..1341a340bfc9c77dc250f5d00753485ab57e2ed0 100644 (file)
@@ -243,9 +243,9 @@ inline void aabb_corners(const AABB& aabb, Vector3 corners[8])
 
 inline void aabb_corners_oriented(const AABB& aabb, const Matrix4& rotation, Vector3 corners[8])
 {
 
 inline void aabb_corners_oriented(const AABB& aabb, const Matrix4& rotation, Vector3 corners[8])
 {
-  Vector3 x = Vector3(rotation.x()) * aabb.extents.x();
-  Vector3 y = Vector3(rotation.y()) * aabb.extents.y();
-  Vector3 z = Vector3(rotation.z()) * aabb.extents.z();
+  Vector3 x = vector4_to_vector3(rotation.x()) * aabb.extents.x();
+  Vector3 y = vector4_to_vector3(rotation.y()) * aabb.extents.y();
+  Vector3 z = vector4_to_vector3(rotation.z()) * aabb.extents.z();
 
   corners[0] = aabb.origin + -x +  y +  z;
   corners[1] = aabb.origin +  x +  y +  z;
 
   corners[0] = aabb.origin + -x +  y +  z;
   corners[1] = aabb.origin +  x +  y +  z;
@@ -269,16 +269,16 @@ inline void aabb_planes(const AABB& aabb, Plane3 planes[6])
 
 inline void aabb_planes_oriented(const AABB& aabb, const Matrix4& rotation, Plane3 planes[6])
 {
 
 inline void aabb_planes_oriented(const AABB& aabb, const Matrix4& rotation, Plane3 planes[6])
 {
-  double x = vector3_dot(Vector3(rotation.x()), aabb.origin);
-  double y = vector3_dot(Vector3(rotation.y()), aabb.origin);
-  double z = vector3_dot(Vector3(rotation.z()), aabb.origin);
-
-  planes[0] = Plane3(Vector3(rotation.x()), x + aabb.extents[0]);
-  planes[1] = Plane3(-Vector3(rotation.x()), -(x - aabb.extents[0]));
-  planes[2] = Plane3(Vector3(rotation.y()), y + aabb.extents[1]);
-  planes[3] = Plane3(-Vector3(rotation.y()), -(y - aabb.extents[1]));
-  planes[4] = Plane3(Vector3(rotation.z()), z + aabb.extents[2]);
-  planes[5] = Plane3(-Vector3(rotation.z()), -(z - aabb.extents[2]));
+  double x = vector3_dot(vector4_to_vector3(rotation.x()), aabb.origin);
+  double y = vector3_dot(vector4_to_vector3(rotation.y()), aabb.origin);
+  double z = vector3_dot(vector4_to_vector3(rotation.z()), aabb.origin);
+
+  planes[0] = Plane3(vector4_to_vector3(rotation.x()), x + aabb.extents[0]);
+  planes[1] = Plane3(-vector4_to_vector3(rotation.x()), -(x - aabb.extents[0]));
+  planes[2] = Plane3(vector4_to_vector3(rotation.y()), y + aabb.extents[1]);
+  planes[3] = Plane3(-vector4_to_vector3(rotation.y()), -(y - aabb.extents[1]));
+  planes[4] = Plane3(vector4_to_vector3(rotation.z()), z + aabb.extents[2]);
+  planes[5] = Plane3(-vector4_to_vector3(rotation.z()), -(z - aabb.extents[2]));
 }
 
 const Vector3 aabb_normals[6] = {
 }
 
 const Vector3 aabb_normals[6] = {
index a9d2a80905ef1d954e7a6f51caf462576e8aa2ef..15c31def3aaf871ef252c3a910c591c9b7d223df 100644 (file)
@@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 /// \file
 /// \brief Vector data types and related operations.
 
 /// \file
 /// \brief Vector data types and related operations.
 
+#include "generic/vector.h"
+
 #if 0
 
 #define        lrint(dbl)              ((int)((dbl) + 0.5))
 #if 0
 
 #define        lrint(dbl)              ((int)((dbl) + 0.5))
@@ -58,7 +60,6 @@ inline int lrint (double flt)
 #endif
 
 #include <cmath>
 #endif
 
 #include <cmath>
-#include <cstddef>
 #include <float.h>
 #include <algorithm>
 
 #include <float.h>
 #include <algorithm>
 
@@ -115,48 +116,6 @@ inline Element float_mod(const Element& self, const ModulusElement& modulus)
 }
 
 
 }
 
 
-template<typename Element>
-class BasicVector2
-{
-  Element m_elements[2];
-public:
-  BasicVector2()
-  {
-  }
-  BasicVector2(const Element& x_, const Element& y_)
-  {
-    x() = x_;
-    y() = y_;
-  }
-
-  Element& x()
-  {
-    return m_elements[0];
-  }
-  const Element& x() const
-  {
-    return m_elements[0];
-  }
-  Element& y()
-  {
-    return m_elements[1];
-  }
-  const Element& y() const
-  {
-    return m_elements[1];
-  }
-
-  const Element& operator[](std::size_t i) const
-  {
-    return m_elements[i];
-  }
-  Element& operator[](std::size_t i)
-  {
-    return m_elements[i];
-  }
-};
-
-
 template<typename Element, typename OtherElement>
 inline BasicVector2<Element> vector2_added(const BasicVector2<Element>& self, const BasicVector2<OtherElement>& other)
 {
 template<typename Element, typename OtherElement>
 inline BasicVector2<Element> vector2_added(const BasicVector2<Element>& self, const BasicVector2<OtherElement>& other)
 {
@@ -335,79 +294,6 @@ inline double vector2_cross(const BasicVector2<Element>& self, const BasicVector
   return self.x() * other.y() - self.y() * other.x();
 }
 
   return self.x() * other.y() - self.y() * other.x();
 }
 
-typedef BasicVector2<float> Vector2;
-
-/// \brief A 3-element vector.
-template<typename Element>
-class BasicVector3
-{
-  Element m_elements[3];
-public:
-
-  BasicVector3()
-  {
-  }
-  template<typename OtherElement>
-  BasicVector3(const BasicVector3<OtherElement>& other)
-  {
-    x() = static_cast<Element>(other.x());
-    y() = static_cast<Element>(other.y());
-    z() = static_cast<Element>(other.z());
-  }
-  BasicVector3(const Element& x_, const Element& y_, const Element& z_)
-  {
-    x() = x_;
-    y() = y_;
-    z() = z_;
-  }
-
-  Element& x()
-  {
-    return m_elements[0];
-  }
-  const Element& x() const
-  {
-    return m_elements[0];
-  }
-  Element& y()
-  {
-    return m_elements[1];
-  }
-  const Element& y() const
-  {
-    return m_elements[1];
-  }
-  Element& z()
-  {
-    return m_elements[2];
-  }
-  const Element& z() const
-  {
-    return m_elements[2];
-  }
-
-  const Element& operator[](std::size_t i) const
-  {
-    return m_elements[i];
-  }
-  Element& operator[](std::size_t i)
-  {
-    return m_elements[i];
-  }
-
-  operator BasicVector2<Element>&()
-  {
-    return reinterpret_cast<BasicVector2<Element>&>(*this);
-  }
-  operator const BasicVector2<Element>&() const
-  {
-    return reinterpret_cast<const BasicVector2<Element>&>(*this);
-  }
-};
-
-/// \brief A 3-element vector stored in single-precision floating-point.
-typedef BasicVector3<float> Vector3;
-
 const Vector3 g_vector3_identity(0, 0, 0);
 const Vector3 g_vector3_max = Vector3(FLT_MAX, FLT_MAX, FLT_MAX);
 const Vector3 g_vector3_axis_x(1, 0, 0);
 const Vector3 g_vector3_identity(0, 0, 0);
 const Vector3 g_vector3_max = Vector3(FLT_MAX, FLT_MAX, FLT_MAX);
 const Vector3 g_vector3_axis_x(1, 0, 0);
@@ -416,26 +302,6 @@ const Vector3 g_vector3_axis_z(0, 0, 1);
 
 const Vector3 g_vector3_axes[3] = { g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z };
 
 
 const Vector3 g_vector3_axes[3] = { g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z };
 
-inline Vector3& vector3_from_array(float* array)
-{
-  return *reinterpret_cast<Vector3*>(array);
-}
-inline const Vector3& vector3_from_array(const float* array)
-{
-  return *reinterpret_cast<const Vector3*>(array);
-}
-
-template<typename Element>
-inline Element* vector3_to_array(BasicVector3<Element>& self)
-{
-  return reinterpret_cast<Element*>(&self);
-}
-template<typename Element>
-inline const Element* vector3_to_array(const BasicVector3<Element>& self)
-{
-  return reinterpret_cast<const Element*>(&self);
-}
-
 template<typename Element, typename OtherElement>
 inline void vector3_swap(BasicVector3<Element>& self, BasicVector3<OtherElement>& other)
 {
 template<typename Element, typename OtherElement>
 inline void vector3_swap(BasicVector3<Element>& self, BasicVector3<OtherElement>& other)
 {
@@ -743,98 +609,6 @@ inline Vector3 vector3_for_spherical(double theta, double phi)
 }
 
 
 }
 
 
-/// \brief A 4-element vector.
-template<typename Element>
-class BasicVector4
-{
-  Element m_elements[4];
-public:
-
-  BasicVector4()
-  {
-  }
-  BasicVector4(Element x_, Element y_, Element z_, Element w_)
-  {
-    x() = x_;
-    y() = y_;
-    z() = z_;
-    w() = w_;
-  }
-  BasicVector4(const BasicVector3<Element>& self, Element w_)
-  {
-    x() = self.x();
-    y() = self.y();
-    z() = self.z();
-    w() = w_;
-  }
-
-  Element& x()
-  {
-    return m_elements[0];
-  }
-  Element x() const
-  {
-    return m_elements[0];
-  }
-  Element& y()
-  {
-    return m_elements[1];
-  }
-  Element y() const
-  {
-    return m_elements[1];
-  }
-  Element& z()
-  {
-    return m_elements[2];
-  }
-  Element z() const
-  {
-    return m_elements[2];
-  }
-  Element& w()
-  {
-    return m_elements[3];
-  }
-  Element w() const
-  {
-    return m_elements[3];
-  }
-
-  Element index(std::size_t i) const
-  {
-    return m_elements[i];
-  }
-  Element& index(std::size_t i)
-  {
-    return m_elements[i];
-  }
-  Element operator[](std::size_t i) const
-  {
-    return m_elements[i];
-  }
-  Element& operator[](std::size_t i)
-  {
-    return m_elements[i];
-  }
-
-  operator BasicVector3<Element>&()
-  {
-    return reinterpret_cast<BasicVector3<Element>&>(*this);
-  }
-  operator const BasicVector3<Element>&() const
-  {
-    return reinterpret_cast<const BasicVector3<Element>&>(*this);
-  }
-
-  bool operator==(const BasicVector4& other) const
-  {
-    return x() == other.x() && y() == other.y() && z() == other.z() && w() == other.w();
-  }
-};
-
-/// \brief A 4-element vector stored in single-precision floating-point.
-typedef BasicVector4<float> Vector4;
 
 
 template<typename Element, typename OtherElement>
 
 
 template<typename Element, typename OtherElement>
@@ -862,28 +636,6 @@ inline bool vector4_equal_epsilon(const BasicVector4<Element>& self, const Basic
     && float_equal_epsilon(self.w(), other.w(), epsilon);
 }
 
     && float_equal_epsilon(self.w(), other.w(), epsilon);
 }
 
-template<typename Element>
-inline Element* vector4_to_array(BasicVector4<Element>& self)
-{
-  return reinterpret_cast<Element*>(&self);
-}
-template<typename Element>
-inline const float* vector4_to_array(const BasicVector4<Element>& self)
-{
-  return reinterpret_cast<const Element*>(&self);
-}
-
-template<typename Element>
-inline Vector3& vector4_to_vector3(BasicVector4<Element>& self)
-{
-  return reinterpret_cast<BasicVector3<Element>&>(self);
-}
-template<typename Element>
-inline const Vector3& vector4_to_vector3(const BasicVector4<Element>& self)
-{
-  return reinterpret_cast<const BasicVector3<Element>&>(self);
-}
-
 template<typename Element, typename OtherElement>
 inline BasicVector4<Element> vector4_added(const BasicVector4<Element>& self, const BasicVector4<OtherElement>& other)
 {
 template<typename Element, typename OtherElement>
 inline BasicVector4<Element> vector4_added(const BasicVector4<Element>& self, const BasicVector4<OtherElement>& other)
 {
index 71b94b7619cd0026cbede5bb49b32e6d9e6e89fb..1411303cc8fc1827a61c6139e09433883f6bda1b 100644 (file)
@@ -360,40 +360,38 @@ inline bool operator!=(const Colour4b& self, const Colour4b& other)
 }
 
 /// \brief A 3-float vertex.
 }
 
 /// \brief A 3-float vertex.
-struct Vertex3f
+struct Vertex3f : public Vector3
 {
 {
-  float x, y, z;
-
   Vertex3f()
   {
   }
 
   Vertex3f(float _x, float _y, float _z)
   Vertex3f()
   {
   }
 
   Vertex3f(float _x, float _y, float _z)
-    : x(_x), y(_y), z(_z)
+    : Vector3(_x, _y, _z)
   {
   }
 };
 
 inline bool operator<(const Vertex3f& self, const Vertex3f& other)
 {
   {
   }
 };
 
 inline bool operator<(const Vertex3f& self, const Vertex3f& other)
 {
-  if(self.x != other.x)
+  if(self.x() != other.x())
   {
   {
-    return self.x < other.x;
+    return self.x() < other.x();
   }
   }
-  if(self.y != other.y)
+  if(self.y() != other.y())
   {
   {
-    return self.y < other.y;
+    return self.y() < other.y();
   }
   }
-  if(self.z != other.z)
+  if(self.z() != other.z())
   {
   {
-    return self.z < other.z;
+    return self.z() < other.z();
   }
   return false;
 }
 
 inline bool operator==(const Vertex3f& self, const Vertex3f& other)
 {
   }
   return false;
 }
 
 inline bool operator==(const Vertex3f& self, const Vertex3f& other)
 {
-  return self.x == other.x && self.y == other.y && self.z == other.z;
+  return self.x() == other.x() && self.y() == other.y() && self.z() == other.z();
 }
 
 inline bool operator!=(const Vertex3f& self, const Vertex3f& other)
 }
 
 inline bool operator!=(const Vertex3f& self, const Vertex3f& other)
@@ -402,9 +400,9 @@ inline bool operator!=(const Vertex3f& self, const Vertex3f& other)
 }
 
 
 }
 
 
-inline const Vertex3f& vertex3f_from_array(const float* array)
+inline Vertex3f vertex3f_from_array(const float* array)
 {
 {
-  return *reinterpret_cast<const Vertex3f*>(array);
+  return Vertex3f(array[0], array[1], array[2]);
 }
 
 inline float* vertex3f_to_array(Vertex3f& vertex)
 }
 
 inline float* vertex3f_to_array(Vertex3f& vertex)
@@ -426,50 +424,48 @@ inline Vertex3f vertex3f_for_vector3(const Vector3& vector3)
 
 inline const Vector3& vertex3f_to_vector3(const Vertex3f& vertex)
 {
 
 inline const Vector3& vertex3f_to_vector3(const Vertex3f& vertex)
 {
-  return reinterpret_cast<const Vector3&>(vertex);
+  return vertex;
 }
 
 inline Vector3& vertex3f_to_vector3(Vertex3f& vertex)
 {
 }
 
 inline Vector3& vertex3f_to_vector3(Vertex3f& vertex)
 {
-  return reinterpret_cast<Vector3&>(vertex);
+  return vertex;
 }
 
 
 /// \brief A 3-float normal.
 }
 
 
 /// \brief A 3-float normal.
-struct Normal3f
+struct Normal3f : public Vector3
 {
 {
-  float x, y, z;
-
   Normal3f()
   {
   }
 
   Normal3f(float _x, float _y, float _z)
   Normal3f()
   {
   }
 
   Normal3f(float _x, float _y, float _z)
-    : x(_x), y(_y), z(_z)
+    : Vector3(_x, _y, _z)
   {
   }
 };
 
 inline bool operator<(const Normal3f& self, const Normal3f& other)
 {
   {
   }
 };
 
 inline bool operator<(const Normal3f& self, const Normal3f& other)
 {
-  if(self.x != other.x)
+  if(self.x() != other.x())
   {
   {
-    return self.x < other.x;
+    return self.x() < other.x();
   }
   }
-  if(self.y != other.y)
+  if(self.y() != other.y())
   {
   {
-    return self.y < other.y;
+    return self.y() < other.y();
   }
   }
-  if(self.z != other.z)
+  if(self.z() != other.z())
   {
   {
-    return self.z < other.z;
+    return self.z() < other.z();
   }
   return false;
 }
 
 inline bool operator==(const Normal3f& self, const Normal3f& other)
 {
   }
   return false;
 }
 
 inline bool operator==(const Normal3f& self, const Normal3f& other)
 {
-  return self.x == other.x && self.y == other.y && self.z == other.z;
+  return self.x() == other.x() && self.y() == other.y() && self.z() == other.z();
 }
 
 inline bool operator!=(const Normal3f& self, const Normal3f& other)
 }
 
 inline bool operator!=(const Normal3f& self, const Normal3f& other)
@@ -500,46 +496,61 @@ inline Normal3f normal3f_for_vector3(const Vector3& vector3)
 
 inline const Vector3& normal3f_to_vector3(const Normal3f& normal)
 {
 
 inline const Vector3& normal3f_to_vector3(const Normal3f& normal)
 {
-  return reinterpret_cast<const Vector3&>(normal);
+  return normal;
 }
 
 inline Vector3& normal3f_to_vector3(Normal3f& normal)
 {
 }
 
 inline Vector3& normal3f_to_vector3(Normal3f& normal)
 {
-  return reinterpret_cast<Vector3&>(normal);
+  return normal;
 }
 
 
 /// \brief A 2-float texture-coordinate set.
 }
 
 
 /// \brief A 2-float texture-coordinate set.
-struct TexCoord2f
+struct TexCoord2f : public Vector2
 {
 {
-  float s, t;
-
   TexCoord2f()
   {
   }
 
   TexCoord2f(float _s, float _t)
   TexCoord2f()
   {
   }
 
   TexCoord2f(float _s, float _t)
-    : s(_s), t(_t)
+    : Vector2(_s, _t)
+  {
+  }
+
+  float& s()
+  {
+    return x();
+  }
+  const float& s() const
+  {
+    return x();
+  }
+  float& t()
+  {
+    return y();
+  }
+  const float& t() const
   {
   {
+    return y();
   }
 };
 
 inline bool operator<(const TexCoord2f& self, const TexCoord2f& other)
 {
   }
 };
 
 inline bool operator<(const TexCoord2f& self, const TexCoord2f& other)
 {
-  if(self.s != other.s)
+  if(self.s() != other.s())
   {
   {
-    return self.s < other.s;
+    return self.s() < other.s();
   }
   }
-  if(self.t != other.t)
+  if(self.t() != other.t())
   {
   {
-    return self.t < other.t;
+    return self.t() < other.t();
   }
   return false;
 }
 
 inline bool operator==(const TexCoord2f& self, const TexCoord2f& other)
 {
   }
   return false;
 }
 
 inline bool operator==(const TexCoord2f& self, const TexCoord2f& other)
 {
-  return self.s == other.s && self.t == other.t;
+  return self.s() == other.s() && self.t() == other.t();
 }
 
 inline bool operator!=(const TexCoord2f& self, const TexCoord2f& other)
 }
 
 inline bool operator!=(const TexCoord2f& self, const TexCoord2f& other)
@@ -570,12 +581,12 @@ inline TexCoord2f texcoord2f_for_vector2(const Vector2& vector2)
 
 inline const Vector2& texcoord2f_to_vector2(const TexCoord2f& vertex)
 {
 
 inline const Vector2& texcoord2f_to_vector2(const TexCoord2f& vertex)
 {
-  return reinterpret_cast<const Vector2&>(vertex);
+  return vertex;
 }
 
 inline Vector2& texcoord2f_to_vector2(TexCoord2f& vertex)
 {
 }
 
 inline Vector2& texcoord2f_to_vector2(TexCoord2f& vertex)
 {
-  return reinterpret_cast<Vector2&>(vertex);
+  return vertex;
 }
 
 /// \brief Returns \p normal rescaled to be unit-length. 
 }
 
 /// \brief Returns \p normal rescaled to be unit-length. 
@@ -600,7 +611,7 @@ enum UnitSphereOctant
 inline UnitSphereOctant normal3f_classify_octant(const Normal3f& normal)
 {
   return static_cast<UnitSphereOctant>(
 inline UnitSphereOctant normal3f_classify_octant(const Normal3f& normal)
 {
   return static_cast<UnitSphereOctant>(
-    ((normal.x > 0) << 0) | ((normal.y > 0) << 1) | ((normal.z > 0) << 2)
+    ((normal.x() > 0) << 0) | ((normal.y() > 0) << 1) | ((normal.z() > 0) << 2)
   );
 }
 
   );
 }
 
@@ -610,21 +621,21 @@ inline Normal3f normal3f_fold_octant(const Normal3f& normal, UnitSphereOctant oc
   switch(octant)
   {
   case UNITSPHEREOCTANT_000:
   switch(octant)
   {
   case UNITSPHEREOCTANT_000:
-    return Normal3f(-normal.x, -normal.y, -normal.z);
+    return Normal3f(-normal.x(), -normal.y(), -normal.z());
   case UNITSPHEREOCTANT_001:
   case UNITSPHEREOCTANT_001:
-    return Normal3f(normal.x, -normal.y, -normal.z);
+    return Normal3f(normal.x(), -normal.y(), -normal.z());
   case UNITSPHEREOCTANT_010:
   case UNITSPHEREOCTANT_010:
-    return Normal3f(-normal.x, normal.y, -normal.z);
+    return Normal3f(-normal.x(), normal.y(), -normal.z());
   case UNITSPHEREOCTANT_011:
   case UNITSPHEREOCTANT_011:
-    return Normal3f(normal.x, normal.y, -normal.z);
+    return Normal3f(normal.x(), normal.y(), -normal.z());
   case UNITSPHEREOCTANT_100:
   case UNITSPHEREOCTANT_100:
-    return Normal3f(-normal.x, -normal.y, normal.z);
+    return Normal3f(-normal.x(), -normal.y(), normal.z());
   case UNITSPHEREOCTANT_101:
   case UNITSPHEREOCTANT_101:
-    return Normal3f(normal.x, -normal.y, normal.z);
+    return Normal3f(normal.x(), -normal.y(), normal.z());
   case UNITSPHEREOCTANT_110:
   case UNITSPHEREOCTANT_110:
-    return Normal3f(-normal.x, normal.y, normal.z);
+    return Normal3f(-normal.x(), normal.y(), normal.z());
   case UNITSPHEREOCTANT_111:
   case UNITSPHEREOCTANT_111:
-    return Normal3f(normal.x, normal.y, normal.z);
+    return Normal3f(normal.x(), normal.y(), normal.z());
   }
   return Normal3f();
 }
   }
   return Normal3f();
 }
@@ -653,14 +664,14 @@ enum UnitSphereSextant
 inline UnitSphereSextant normal3f_classify_sextant(const Normal3f& normal)
 {
   return
 inline UnitSphereSextant normal3f_classify_sextant(const Normal3f& normal)
 {
   return
-    normal.x >= normal.y
-    ? normal.x >= normal.z
-      ? normal.y >= normal.z
+    normal.x() >= normal.y()
+    ? normal.x() >= normal.z()
+      ? normal.y() >= normal.z()
         ? UNITSPHERESEXTANT_XYZ
         : UNITSPHERESEXTANT_XZY
         : UNITSPHERESEXTANT_ZXY
         ? UNITSPHERESEXTANT_XYZ
         : UNITSPHERESEXTANT_XZY
         : UNITSPHERESEXTANT_ZXY
-        : normal.y >= normal.z
-        ? normal.x >= normal.z
+        : normal.y() >= normal.z()
+        ? normal.x() >= normal.z()
         ? UNITSPHERESEXTANT_YXZ
         : UNITSPHERESEXTANT_YZX
         : UNITSPHERESEXTANT_ZYX;
         ? UNITSPHERESEXTANT_YXZ
         : UNITSPHERESEXTANT_YZX
         : UNITSPHERESEXTANT_ZYX;
@@ -674,17 +685,17 @@ inline Normal3f normal3f_fold_sextant(const Normal3f& normal, UnitSphereSextant
   switch(sextant)
   {
   case UNITSPHERESEXTANT_XYZ:
   switch(sextant)
   {
   case UNITSPHERESEXTANT_XYZ:
-    return Normal3f(normal.x, normal.y, normal.z);
+    return Normal3f(normal.x(), normal.y(), normal.z());
   case UNITSPHERESEXTANT_XZY:
   case UNITSPHERESEXTANT_XZY:
-    return Normal3f(normal.x, normal.z, normal.y);
+    return Normal3f(normal.x(), normal.z(), normal.y());
   case UNITSPHERESEXTANT_YXZ:
   case UNITSPHERESEXTANT_YXZ:
-    return Normal3f(normal.y, normal.x, normal.z);
+    return Normal3f(normal.y(), normal.x(), normal.z());
   case UNITSPHERESEXTANT_YZX:
   case UNITSPHERESEXTANT_YZX:
-    return Normal3f(normal.y, normal.z, normal.x);
+    return Normal3f(normal.y(), normal.z(), normal.x());
   case UNITSPHERESEXTANT_ZXY:
   case UNITSPHERESEXTANT_ZXY:
-    return Normal3f(normal.z, normal.x, normal.y);
+    return Normal3f(normal.z(), normal.x(), normal.y());
   case UNITSPHERESEXTANT_ZYX:
   case UNITSPHERESEXTANT_ZYX:
-    return Normal3f(normal.z, normal.y, normal.x);
+    return Normal3f(normal.z(), normal.y(), normal.x());
   }
   return Normal3f();
 }
   }
   return Normal3f();
 }
@@ -703,9 +714,9 @@ const std::size_t c_quantise_normal = 1 << 6;
 inline Normal3f normal3f_folded_quantised(const Normal3f& folded)
 {
   // compress
 inline Normal3f normal3f_folded_quantised(const Normal3f& folded)
 {
   // compress
-  double scale = static_cast<float>(c_quantise_normal) / (folded.x + folded.y + folded.z);
-  unsigned int zbits = static_cast<unsigned int>(folded.z * scale);
-  unsigned int ybits = static_cast<unsigned int>(folded.y * scale);
+  double scale = static_cast<float>(c_quantise_normal) / (folded.x() + folded.y() + folded.z());
+  unsigned int zbits = static_cast<unsigned int>(folded.z() * scale);
+  unsigned int ybits = static_cast<unsigned int>(folded.y() * scale);
 
   // decompress
   return normal3f_normalised(Normal3f(
 
   // decompress
   return normal3f_normalised(Normal3f(
@@ -762,7 +773,7 @@ struct uniformspherical_t
 
 inline spherical_t spherical_from_normal3f(const Normal3f& normal)
 {
 
 inline spherical_t spherical_from_normal3f(const Normal3f& normal)
 {
-  return spherical_t(normal.x == 0 ? c_pi / 2 : normal.x > 0 ? atan(normal.y / normal.x) : atan(normal.y / normal.x) + c_pi, acos(normal.z));
+  return spherical_t(normal.x() == 0 ? c_pi / 2 : normal.x() > 0 ? atan(normal.y() / normal.x()) : atan(normal.y() / normal.x()) + c_pi, acos(normal.z()));
 }
 
 inline Normal3f normal3f_from_spherical(const spherical_t& spherical)
 }
 
 inline Normal3f normal3f_from_spherical(const spherical_t& spherical)
@@ -820,7 +831,7 @@ inline uniformspherical_t uniformspherical_quantised(const uniformspherical_t& u
 /// \brief Returns a \p vertex quantised to \p precision.
 inline Vertex3f vertex3f_quantised(const Vertex3f& vertex, float precision)
 {
 /// \brief Returns a \p vertex quantised to \p precision.
 inline Vertex3f vertex3f_quantised(const Vertex3f& vertex, float precision)
 {
-  return Vertex3f(float_quantise(vertex.x, precision), float_quantise(vertex.y, precision), float_quantise(vertex.z, precision));
+  return Vertex3f(float_quantise(vertex.x(), precision), float_quantise(vertex.y(), precision), float_quantise(vertex.z(), precision));
 }
 
 /// \brief Returns a \p normal quantised to a fixed precision.
 }
 
 /// \brief Returns a \p normal quantised to a fixed precision.
@@ -835,7 +846,7 @@ inline Normal3f normal3f_quantised(const Normal3f& normal)
 /// \brief Returns a \p texcoord quantised to \p precision.
 inline TexCoord2f texcoord2f_quantised(const TexCoord2f& texcoord, float precision)
 {
 /// \brief Returns a \p texcoord quantised to \p precision.
 inline TexCoord2f texcoord2f_quantised(const TexCoord2f& texcoord, float precision)
 {
-  return TexCoord2f(float_quantise(texcoord.s, precision), float_quantise(texcoord.t, precision));
+  return TexCoord2f(float_quantise(texcoord.s(), precision), float_quantise(texcoord.t(), precision));
 }
 
 /// \brief Standard vertex type for lines and points.
 }
 
 /// \brief Standard vertex type for lines and points.
@@ -1071,9 +1082,9 @@ class RemapXYZ
 public:
   static void set(Vertex3f& vertex, float x, float y, float z)
   {
 public:
   static void set(Vertex3f& vertex, float x, float y, float z)
   {
-    vertex.x = x;
-    vertex.y = y;
-    vertex.z = z;
+    vertex.x() = x;
+    vertex.y() = y;
+    vertex.z() = z;
   }
 };
 
   }
 };
 
@@ -1082,9 +1093,9 @@ class RemapYZX
 public:
   static void set(Vertex3f& vertex, float x, float y, float z)
   {
 public:
   static void set(Vertex3f& vertex, float x, float y, float z)
   {
-    vertex.x = z;
-    vertex.y = x;
-    vertex.z = y;
+    vertex.x() = z;
+    vertex.y() = x;
+    vertex.z() = y;
   }
 };
 
   }
 };
 
@@ -1093,9 +1104,9 @@ class RemapZXY
 public:
   static void set(Vertex3f& vertex, float x, float y, float z)
   {
 public:
   static void set(Vertex3f& vertex, float x, float y, float z)
   {
-    vertex.x = y;
-    vertex.y = z;
-    vertex.z = x;
+    vertex.x() = y;
+    vertex.y() = z;
+    vertex.z() = x;
   }
 };
 
   }
 };
 
@@ -1267,12 +1278,12 @@ inline void ArbitraryMeshTriangle_calcTangents(const ArbitraryMeshVertex& a, con
     Vector3 cross(
       vector3_cross(
         vector3_subtracted(
     Vector3 cross(
       vector3_cross(
         vector3_subtracted(
-          Vector3(b.vertex.x, b.texcoord.s, b.texcoord.t),
-          Vector3(a.vertex.x, a.texcoord.s, a.texcoord.t)
+          Vector3(b.vertex.x(), b.texcoord.s(), b.texcoord.t()),
+          Vector3(a.vertex.x(), a.texcoord.s(), a.texcoord.t())
         ),
         vector3_subtracted(
         ),
         vector3_subtracted(
-          Vector3(c.vertex.x, c.texcoord.s, c.texcoord.t),
-          Vector3(a.vertex.x, a.texcoord.s, a.texcoord.t)
+          Vector3(c.vertex.x(), c.texcoord.s(), c.texcoord.t()),
+          Vector3(a.vertex.x(), a.texcoord.s(), a.texcoord.t())
         )
       )
     );
         )
       )
     );
@@ -1292,12 +1303,12 @@ inline void ArbitraryMeshTriangle_calcTangents(const ArbitraryMeshVertex& a, con
     Vector3 cross(
       vector3_cross(
         vector3_subtracted(
     Vector3 cross(
       vector3_cross(
         vector3_subtracted(
-          Vector3(b.vertex.y, b.texcoord.s, b.texcoord.t),
-          Vector3(a.vertex.y, a.texcoord.s, a.texcoord.t)
+          Vector3(b.vertex.y(), b.texcoord.s(), b.texcoord.t()),
+          Vector3(a.vertex.y(), a.texcoord.s(), a.texcoord.t())
         ),
         vector3_subtracted(
         ),
         vector3_subtracted(
-          Vector3(c.vertex.y, c.texcoord.s, c.texcoord.t),
-          Vector3(a.vertex.y, a.texcoord.s, a.texcoord.t)
+          Vector3(c.vertex.y(), c.texcoord.s(), c.texcoord.t()),
+          Vector3(a.vertex.y(), a.texcoord.s(), a.texcoord.t())
         )
       )
     );
         )
       )
     );
@@ -1317,12 +1328,12 @@ inline void ArbitraryMeshTriangle_calcTangents(const ArbitraryMeshVertex& a, con
     Vector3 cross(
       vector3_cross(
         vector3_subtracted(
     Vector3 cross(
       vector3_cross(
         vector3_subtracted(
-          Vector3(b.vertex.z, b.texcoord.s, b.texcoord.t),
-          Vector3(a.vertex.z, a.texcoord.s, a.texcoord.t)
+          Vector3(b.vertex.z(), b.texcoord.s(), b.texcoord.t()),
+          Vector3(a.vertex.z(), a.texcoord.s(), a.texcoord.t())
         ),
         vector3_subtracted(
         ),
         vector3_subtracted(
-          Vector3(c.vertex.z, c.texcoord.s, c.texcoord.t),
-          Vector3(a.vertex.z, a.texcoord.s, a.texcoord.t)
+          Vector3(c.vertex.z(), c.texcoord.s(), c.texcoord.t()),
+          Vector3(a.vertex.z(), a.texcoord.s(), a.texcoord.t())
         )
       )
     );
         )
       )
     );
index 52407c13e70f79429e101005a4e56208d689d63a..8a8bd9b98e72ca2303e44c7a72f8def4961a6128 100644 (file)
@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <stdlib.h>
 #include <cctype>
 
 #include <stdlib.h>
 #include <cctype>
 
-#include "math/vector.h"
+#include "generic/vector.h"
 #include "iscriplib.h"
 #include "string/string.h"
 #include "generic/callback.h"
 #include "iscriplib.h"
 #include "string/string.h"
 #include "generic/callback.h"
index ca03426d2b1b775c288e46cfc9b712671d153b36..8b44597ea41616ca2bf99d2a32d9a1bbd3d80ce2 100644 (file)
@@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #if !defined (INCLUDED_TEXTURELIB_H)
 #define INCLUDED_TEXTURELIB_H
 
 #if !defined (INCLUDED_TEXTURELIB_H)
 #define INCLUDED_TEXTURELIB_H
 
-#include "math/vector.h"
+#include "generic/vector.h"
 typedef Vector3 Colour3;
 typedef unsigned int GLuint;
 class LoadImageCallback;
 typedef Vector3 Colour3;
 typedef unsigned int GLuint;
 class LoadImageCallback;
index 82dd43afa0dd87dae70b5700dd211818d2e6ff0e..f9081d880e6056f910da4471431c078c08164c45 100644 (file)
@@ -398,7 +398,7 @@ public:
       return childBounds.origin;
     }
 #endif
       return childBounds.origin;
     }
 #endif
-    return localToWorld().t();
+    return vector4_to_vector3(localToWorld().t());
   }
 
   void render(Renderer& renderer, const VolumeTest& volume) const
   }
 
   void render(Renderer& renderer, const VolumeTest& volume) const
index bf02f6696ba32582023680a09a11a90f27d73f7b..9ce15a76ff95fee4858c2d13a53db1535f653046 100644 (file)
@@ -298,7 +298,7 @@ bool MD5Model_parse(Model& model, Tokeniser& tokeniser)
     MD5_RETURN_FALSE_IF_FAIL(MD5_parseString(tokeniser, jointName));
     MD5_RETURN_FALSE_IF_FAIL(MD5_parseInteger(tokeniser, (*i).parent));
     MD5_RETURN_FALSE_IF_FAIL(MD5_parseVector3(tokeniser, (*i).position));
     MD5_RETURN_FALSE_IF_FAIL(MD5_parseString(tokeniser, jointName));
     MD5_RETURN_FALSE_IF_FAIL(MD5_parseInteger(tokeniser, (*i).parent));
     MD5_RETURN_FALSE_IF_FAIL(MD5_parseVector3(tokeniser, (*i).position));
-    MD5_RETURN_FALSE_IF_FAIL(MD5_parseVector3(tokeniser, (*i).rotation));
+    MD5_RETURN_FALSE_IF_FAIL(MD5_parseVector3(tokeniser, vector4_to_vector3((*i).rotation)));
     (*i).rotation.w() = -static_cast<float>(sqrt(1.0f - (float_squared((*i).rotation.x()) + float_squared((*i).rotation.y()) + float_squared((*i).rotation.z()))));
     tokeniser.nextLine();
   }
     (*i).rotation.w() = -static_cast<float>(sqrt(1.0f - (float_squared((*i).rotation.x()) + float_squared((*i).rotation.y()) + float_squared((*i).rotation.z()))));
     tokeniser.nextLine();
   }
index b8cc5d38719304479a90f6fdb2bf20c8fd44fbce..02b821ddcfe0657fd53d790f430e975ec182f7fe 100644 (file)
@@ -255,17 +255,17 @@ void Texdef_basisForNormal(const TextureProjection& projection, const Vector3& n
   if(g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_BRUSHPRIMITIVES)
   {
     basis = g_matrix4_identity;
   if(g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_BRUSHPRIMITIVES)
   {
     basis = g_matrix4_identity;
-    ComputeAxisBase(normal, basis.x(), basis.y());
-    static_cast<Vector3&>(basis.z()) = normal;
+    ComputeAxisBase(normal, vector4_to_vector3(basis.x()), vector4_to_vector3(basis.y()));
+    vector4_to_vector3(basis.z()) = normal;
     matrix4_transpose(basis);
     //DebugAxisBase(normal);
   }
   else if(g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_HALFLIFE)
   {
     basis = g_matrix4_identity;
     matrix4_transpose(basis);
     //DebugAxisBase(normal);
   }
   else if(g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_HALFLIFE)
   {
     basis = g_matrix4_identity;
-    static_cast<Vector3&>(basis.x()) = projection.m_basis_s;
-    static_cast<Vector3&>(basis.y()) = vector3_negated(projection.m_basis_t);
-    static_cast<Vector3&>(basis.z()) = vector3_normalised(vector3_cross(static_cast<Vector3&>(basis.x()), static_cast<Vector3&>(basis.y())));
+    vector4_to_vector3(basis.x()) = projection.m_basis_s;
+    vector4_to_vector3(basis.y()) = vector3_negated(projection.m_basis_t);
+    vector4_to_vector3(basis.z()) = vector3_normalised(vector3_cross(vector4_to_vector3(basis.x()), vector4_to_vector3(basis.y())));
     matrix4_multiply_by_matrix4(basis, matrix4_rotation_for_z_degrees(-projection.m_texdef.rotate));
     //globalOutputStream() << "debug: " << projection.m_basis_s << projection.m_basis_t << normal << "\n";
     matrix4_transpose(basis);
     matrix4_multiply_by_matrix4(basis, matrix4_rotation_for_z_degrees(-projection.m_texdef.rotate));
     //globalOutputStream() << "debug: " << projection.m_basis_s << projection.m_basis_t << normal << "\n";
     matrix4_transpose(basis);
@@ -1447,8 +1447,8 @@ void BP_from_matrix(brushprimit_texdef_t& bp_texdef, const Vector3& normal, cons
 {
   Matrix4 basis;
   basis = g_matrix4_identity;
 {
   Matrix4 basis;
   basis = g_matrix4_identity;
-  ComputeAxisBase(normal, basis.x(), basis.y());
-  static_cast<Vector3&>(basis.z()) = normal;
+  ComputeAxisBase(normal, vector4_to_vector3(basis.x()), vector4_to_vector3(basis.y()));
+  vector4_to_vector3(basis.z()) = normal;
   matrix4_transpose(basis);
   matrix4_affine_invert(basis);
 
   matrix4_transpose(basis);
   matrix4_affine_invert(basis);
 
index c7b6344f4a469adf22b2f0362acc69b3cbc5c9ac..719e2412d58763ce30858b2604bd0b8104f3f5f7 100644 (file)
@@ -2212,24 +2212,15 @@ void Patch::BuildTesselationCurves(EMatrixMajor major)
 
 inline void vertex_assign_ctrl(ArbitraryMeshVertex& vertex, const PatchControl& ctrl)
 {
 
 inline void vertex_assign_ctrl(ArbitraryMeshVertex& vertex, const PatchControl& ctrl)
 {
-  vertex.vertex.x = ctrl.m_vertex[0];
-  vertex.vertex.y = ctrl.m_vertex[1];
-  vertex.vertex.z = ctrl.m_vertex[2];
-  vertex.texcoord.s = ctrl.m_texcoord[0];
-  vertex.texcoord.t = ctrl.m_texcoord[1];
+  vertex.vertex = vertex3f_for_vector3(ctrl.m_vertex);
+  vertex.texcoord = texcoord2f_for_vector2(ctrl.m_texcoord);
 }
 
 inline void vertex_clear_normal(ArbitraryMeshVertex& vertex)
 {
 }
 
 inline void vertex_clear_normal(ArbitraryMeshVertex& vertex)
 {
-  vertex.normal.x = 0;
-  vertex.normal.y = 0;
-  vertex.normal.z = 0;
-  vertex.tangent.x = 0;
-  vertex.tangent.y = 0;
-  vertex.tangent.z = 0;
-  vertex.bitangent.x = 0;
-  vertex.bitangent.y = 0;
-  vertex.bitangent.z = 0;
+  vertex.normal = Normal3f(0, 0, 0);
+  vertex.tangent = Normal3f(0, 0, 0);
+  vertex.bitangent = Normal3f(0, 0, 0);
 }
       
 inline void tangents_remove_degenerate(Vector3 tangents[6], Vector2 textureTangents[6], unsigned int flags)
 }
       
 inline void tangents_remove_degenerate(Vector3 tangents[6], Vector2 textureTangents[6], unsigned int flags)
index bea33119a85263539951c213b7b11b4c88c0f351..e4c20e4e7ec261e3e6a60526c7efb3b3e9f7af55 100644 (file)
@@ -1720,7 +1720,7 @@ public:
 
     if(m_dragPlanes.isSelected()) // this should only be true when the transform is a pure translation.
     {
 
     if(m_dragPlanes.isSelected()) // this should only be true when the transform is a pure translation.
     {
-      m_patch.transform(m_dragPlanes.evaluateTransform(matrix.t()));
+      m_patch.transform(m_dragPlanes.evaluateTransform(vector4_to_vector3(matrix.t())));
     }
   }
 
     }
   }
 
index e6142d4e28aed33b46480819147e667f1526d007..75dbbaeefd69098be90f24ffddb4bb263e35f12e 100644 (file)
@@ -476,9 +476,7 @@ public:
     for(std::size_t i=0; i<count; ++i)
     {
       Vector3 world_point(vector4_projected(matrix4_transformed_vector4(m_inverse, clipped[i])));
     for(std::size_t i=0; i<count; ++i)
     {
       Vector3 world_point(vector4_projected(matrix4_transformed_vector4(m_inverse, clipped[i])));
-      m_primitives.back().m_points[i].vertex.x = world_point[0];
-      m_primitives.back().m_points[i].vertex.y = world_point[1];
-      m_primitives.back().m_points[i].vertex.z = world_point[2];
+      m_primitives.back().m_points[i].vertex = vertex3f_for_vector3(world_point);
     }
   }
 
     }
   }
 
@@ -640,7 +638,7 @@ void BestPoint(std::size_t count, Vector4 clipped[9], SelectionIntersection& bes
     Point3D point = segment_closest_point_to_point(segment, Vector3(0, 0, 0));
     assign_if_closer(best, SelectionIntersection(point.z(), 0));
   }
     Point3D point = segment_closest_point_to_point(segment, Vector3(0, 0, 0));
     assign_if_closer(best, SelectionIntersection(point.z(), 0));
   }
-  else if(count > 2 && !point_test_polygon_2d(Vector4(0, 0, 0, 0), normalised, normalised + count))
+  else if(count > 2 && !point_test_polygon_2d(Vector3(0, 0, 0), normalised, normalised + count))
   {
     point_iterator_t end = normalised + count;
     for(point_iterator_t previous = end-1, current = normalised; current != end; previous = current, ++current)
   {
     point_iterator_t end = normalised + count;
     for(point_iterator_t previous = end-1, current = normalised; current != end; previous = current, ++current)
@@ -1252,15 +1250,15 @@ class TripleRemapXYZ
 public:
   static float& x(Triple& triple)
   {
 public:
   static float& x(Triple& triple)
   {
-    return triple.x;
+    return triple.x();
   }
   static float& y(Triple& triple)
   {
   }
   static float& y(Triple& triple)
   {
-    return triple.y;
+    return triple.y();
   }
   static float& z(Triple& triple)
   {
   }
   static float& z(Triple& triple)
   {
-    return triple.z;
+    return triple.z();
   }
 };
 
   }
 };
 
@@ -1270,15 +1268,15 @@ class TripleRemapYZX
 public:
   static float& x(Triple& triple)
   {
 public:
   static float& x(Triple& triple)
   {
-    return triple.y;
+    return triple.y();
   }
   static float& y(Triple& triple)
   {
   }
   static float& y(Triple& triple)
   {
-    return triple.z;
+    return triple.z();
   }
   static float& z(Triple& triple)
   {
   }
   static float& z(Triple& triple)
   {
-    return triple.x;
+    return triple.x();
   }
 };
 
   }
 };
 
@@ -1288,15 +1286,15 @@ class TripleRemapZXY
 public:
   static float& x(Triple& triple)
   {
 public:
   static float& x(Triple& triple)
   {
-    return triple.z;
+    return triple.z();
   }
   static float& y(Triple& triple)
   {
   }
   static float& y(Triple& triple)
   {
-    return triple.x;
+    return triple.x();
   }
   static float& z(Triple& triple)
   {
   }
   static float& z(Triple& triple)
   {
-    return triple.y;
+    return triple.y();
   }
 };
 
   }
 };
 
@@ -3580,11 +3578,11 @@ inline AABB Instance_getPivotBounds(scene::Instance& instance)
     Editable* editable = Node_getEditable(instance.path().top());
     if(editable != 0)
     {
     Editable* editable = Node_getEditable(instance.path().top());
     if(editable != 0)
     {
-      return AABB(matrix4_multiplied_by_matrix4(instance.localToWorld(), editable->getLocalPivot()).t(), Vector3(0, 0, 0));
+      return AABB(vector4_to_vector3(matrix4_multiplied_by_matrix4(instance.localToWorld(), editable->getLocalPivot()).t()), Vector3(0, 0, 0));
     }
     else
     {
     }
     else
     {
-      return AABB(instance.localToWorld().t(), Vector3(0, 0, 0));
+      return AABB(vector4_to_vector3(instance.localToWorld().t()), Vector3(0, 0, 0));
     }
   }
 
     }
   }
 
index 9f201e36201d58ae570c9dfb9f27e0f1cc3b63ed..b6dc414a15126fb92cc0f7a38cc77ac8ea06e2ee 100644 (file)
@@ -204,7 +204,7 @@ public:
   }
   const Vector3& getViewer() const
   {
   }
   const Vector3& getViewer() const
   {
-    return m_viewer;
+    return vector4_to_vector3(m_viewer);
   }
 };
 
   }
 };