server/dep/include/g3dlite/G3D/Vector2int16.h
Lynx3d ae3ad10bcf [10097] Update G3D up to v8.0b4
+ Got rid of zip lib requirement in G3D...
  Still can re-enable code by defining _HAVE_ZIP...

+ Remove silly X11 lib dependency from G3D
  Code doesn't seem to do anything yet anyway, and even if, we don't want it :p

+ Fix another weird G3D build problem...

+ Remove some __asm usage in g3d, which is not available on Win64
  My editor also decided to remove a ton of trailing white spaces...tss...

+ Reapply G3D fixes for 64bit VC

+ not use SSE specific header when SSE not enabled in *nix

+ Updated project files

+ New vmap_assembler VC90/VC80 Project

+ vmap assembler binaries updates

NOTE: Old vmap fikes expected work (as tests show) with new library version.
      But better use new generated versions. Its different in small parts to bad or good...

(based on Lynx3d's repo commit 44798d3)

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
2010-06-23 06:45:25 +04:00

127 lines
3.2 KiB
C++

/**
@file Vector2int16.h
@maintainer Morgan McGuire, matrix@brown.edu
@created 2003-08-09
@edited 2004-01-03
Copyright 2000-2006, Morgan McGuire.
All rights reserved.
*/
#ifndef VECTOR2INT16_H
#define VECTOR2INT16_H
#include "G3D/platform.h"
#include "G3D/g3dmath.h"
#include "G3D/HashTrait.h"
namespace G3D {
/**
\class Vector2int16
A Vector2 that packs its fields into uint16s.
*/
G3D_BEGIN_PACKED_CLASS(2)
class Vector2int16 {
private:
// Hidden operators
bool operator<(const Vector2int16&) const;
bool operator>(const Vector2int16&) const;
bool operator<=(const Vector2int16&) const;
bool operator>=(const Vector2int16&) const;
public:
G3D::int16 x;
G3D::int16 y;
Vector2int16() : x(0), y(0) {}
Vector2int16(G3D::int16 _x, G3D::int16 _y) : x(_x), y(_y){}
Vector2int16(const class Vector2& v);
Vector2int16(class BinaryInput& bi);
inline G3D::int16& operator[] (int i) {
debugAssert(((unsigned int)i) <= 1);
return ((G3D::int16*)this)[i];
}
inline const G3D::int16& operator[] (int i) const {
debugAssert(((unsigned int)i) <= 1);
return ((G3D::int16*)this)[i];
}
inline Vector2int16 operator+(const Vector2int16& other) const {
return Vector2int16(x + other.x, y + other.y);
}
inline Vector2int16 operator-(const Vector2int16& other) const {
return Vector2int16(x - other.x, y - other.y);
}
inline Vector2int16 operator*(const Vector2int16& other) const {
return Vector2int16(x * other.x, y * other.y);
}
inline Vector2int16 operator*(const int s) const {
return Vector2int16(x * s, y * s);
}
inline Vector2int16& operator+=(const Vector2int16& other) {
x += other.x;
y += other.y;
return *this;
}
/** Shifts both x and y */
inline Vector2int16 operator>>(const int s) const {
return Vector2int16(x >> s, y >> s);
}
/** Shifts both x and y */
inline Vector2int16 operator<<(const int s) const {
return Vector2int16(x << s, y << s);
}
inline Vector2int16& operator-=(const Vector2int16& other) {
x -= other.x;
y -= other.y;
return *this;
}
inline Vector2int16& operator*=(const Vector2int16& other) {
x *= other.x;
y *= other.y;
return *this;
}
Vector2int16 clamp(const Vector2int16& lo, const Vector2int16& hi);
inline bool operator== (const Vector2int16& rkVector) const {
return ((int32*)this)[0] == ((int32*)&rkVector)[0];
}
inline bool operator!= (const Vector2int16& rkVector) const {
return ((int32*)this)[0] != ((int32*)&rkVector)[0];
}
Vector2int16 max(const Vector2int16& v) const {
return Vector2int16(iMax(x, v.x), iMax(y, v.y));
}
Vector2int16 min(const Vector2int16& v) const {
return Vector2int16(iMin(x, v.x), iMin(y, v.y));
}
void serialize(class BinaryOutput& bo) const;
void deserialize(class BinaryInput& bi);
}
G3D_END_PACKED_CLASS(2)
}
template<> struct HashTrait<G3D::Vector2int16> {
static size_t hashCode(const G3D::Vector2int16& key) { return static_cast<size_t>(key.x + ((int)key.y << 16)); }
};
#endif