Commit a8b3ac27 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Revert "Brings back reference semantics to tgt::Vector4::xyz() and similar:"

This reverts commit cedb7a00.
parent a71451fa
......@@ -79,7 +79,6 @@ struct Matrix2 {
};
T elemRowCol[2][2];
T elem[4];
Vector2<T> columns[cols];
};
/*
......@@ -163,15 +162,15 @@ struct Matrix2 {
*/
/// return arbitrary row-vector similar to GLSL. <br>
/// BUT REMEMBER: GLSL gives you COLS NOT ROWS!
const Vector2<T>& operator [] (size_t i) const {
tgtAssert(i < cols, "i must be less than size");
return columns[i];
Vector2<T> operator [] (size_t i) const {
tgtAssert(i < size, "i must be less than size");
return Vector2<T>(elemRowCol[i]);
}
/// return arbitrary row-vector similar to GLSL. <br>
/// BUT REMEMBER: GLSL gives you COLS NOT ROWS!
Vector2<T>& operator [] (size_t i) {
tgtAssert(i < cols, "i must be less than size");
return columns[i];
Vector2<T> operator [] (size_t i) {
tgtAssert(i < size, "i must be less than size");
return Vector2<T>(elemRowCol[i]);
}
};
......@@ -219,7 +218,6 @@ struct Matrix3 {
};
T elemRowCol[3][3];
T elem[9];
Vector3<T> columns[cols];
};
/*
......@@ -363,15 +361,15 @@ struct Matrix3 {
*/
/// return arbitrary row-vector similar to GLSL. <br>
/// BUT REMEMBER: GLSL gives you COLS NOT ROWS!
const Vector3<T>& operator [] (size_t i) const {
tgtAssert(i < cols, "i must be less than size");
return columns[i];
Vector3<T> operator [] (size_t i) const {
tgtAssert(i < size, "i must be less than size");
return Vector3<T>(elemRowCol[i]);
}
/// return arbitrary row-vector similar to GLSL. <br>
/// BUT REMEMBER: GLSL gives you COLS NOT ROWS!
Vector3<T>& operator [] (size_t i) {
tgtAssert(i < cols, "i must be less than size");
return columns[i];
Vector3<T> operator [] (size_t i) {
tgtAssert(i < size, "i must be less than size");
return Vector3<T>(elemRowCol[i]);
}
};
......@@ -450,7 +448,6 @@ struct Matrix4 {
};
T elemRowCol[4][4];
T elem[16];
Vector4<T> columns[cols];
};
/*
......@@ -633,15 +630,15 @@ struct Matrix4 {
*/
/// return arbitrary row-vector similar to GLSL. <br>
/// BUT REMEMBER: GLSL gives you COLS NOT ROWS!
const Vector4<T>& operator [] (size_t i) const {
tgtAssert(i < cols, "i must be less than size");
return columns[i];
Vector4<T> operator [] (size_t i) const {
tgtAssert(i < size, "i must be less than size");
return Vector4<T>(elemRowCol[i]);
}
/// return arbitrary row-vector similar to GLSL. <br>
/// BUT REMEMBER: GLSL gives you COLS NOT ROWS!
Vector4<T>& operator [] (size_t i) {
tgtAssert(i < cols, "i must be less than size");
return columns[i];
Vector4<T> operator [] (size_t i) {
tgtAssert(i < size, "i must be less than size");
return Vector4<T>(elemRowCol[i]);
}
/**
......
......@@ -213,9 +213,6 @@ struct Vector2 {
for (size_t i = 0; i < v.size; ++i)
elem[i] = T(v.elem[i]);
}
static Vector2<T> createAsReference(T* v) {
}
/// Index operator
const T& operator [] (size_t index) const {
......@@ -266,13 +263,9 @@ struct Vector3 {
// workaround to prevent "dereferencing type-punned pointer will break strict-aliasing
// rules" warning with gcc and -fstrict-aliasing.
struct {
Vector2<T> _xy;
T _xy[size-1];
T _z;
};
struct {
T _x;
Vector2<T> _yz;
};
T elem[size];
};
......@@ -329,17 +322,17 @@ struct Vector3 {
/*
sub-vector getters
*/
const Vector2<T>& xy() const {
return _xy;
Vector2<T> xy() const {
return Vector2<T>(_xy);
}
Vector2<T>& xy() {
return _xy;
Vector2<T> xy() {
return Vector2<T>(_xy);
}
const Vector2<T>& yz() const {
return _yz;
Vector2<T> yz() const {
return Vector2<T>(elem + 1);
}
Vector2<T>& yz() {
return _yz;
Vector2<T> yz() {
return Vector2<T>(elem + 1);
}
/*
......@@ -387,22 +380,9 @@ struct Vector4 {
// workaround to prevent "dereferencing type-punned pointer will break strict-aliasing
// rules" warning with gcc and -fstrict-aliasing.
struct {
Vector3<T> _xyz;
T _xyz[size-1];
T _w;
};
struct {
T _x;
Vector3<T> _yzw;
};
struct {
Vector2<T> _xy;
Vector2<T> _zw;
};
struct {
T __x;
Vector2<T> _yz;
T __w;
};
T elem[size];
};
......@@ -487,35 +467,35 @@ struct Vector4 {
sub-vector getters
*/
const Vector2<T>& xy() const {
return _xy;
Vector2<T> xy() const {
return xyz().xy();
}
const Vector2<T>& yz() const {
return _yz;
Vector2<T> yz() const {
return Vector2<T>(elem + 1);
}
const Vector2<T>& zw() const {
return _zw;
Vector2<T> zw() const {
return Vector2<T>(elem + 2);
}
const Vector3<T>& xyz() const {
return _xyz;
Vector3<T> xyz() const {
return Vector3<T>(_xyz);
}
const Vector3<T>& yzw() const {
return _yzw;
Vector3<T> yzw() const {
return Vector3<T>(elem + 1);
}
Vector2<T> xy() {
return _xy;
return xyz().xy();
}
Vector2<T> yz() {
return _yz;
return Vector2<T>(elem + 1);
}
Vector2<T> zw() {
return _zw;
return Vector2<T>(elem + 2);
}
Vector3<T> xyz() {
return _xyz;
return Vector3<T>(_xyz);
}
Vector3<T> yzw() {
return _yzw;
return Vector3<T>(elem + 1);
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment