2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

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

Fixed tgt::Matrix and tgt::Vector breaking strict aliasing rules. Fixed some GCC warnings.

parent 99a32bd0
......@@ -119,7 +119,7 @@ IF(WIN32)
ELSEIF(UNIX)
LIST(APPEND CampvisGlobalDefinitions "-DUNIX")
LIST(APPEND CampvisGlobalDefinitions "-Wall")
LIST(APPEND CampvisGlobalDefinitions "-Wall -Wno-unused-local-typedefs -Wno-unused-variable")
LIST(APPEND CampvisGlobalDefinitions "-D__STDC_CONSTANT_MACROS")
# disable tree-vrp optimization in gcc, which for some strange reason breaks tgt's matrix code...
......
......@@ -162,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 {
Vector2<T> operator [] (size_t i) const {
tgtAssert(i < size, "i must be less than size");
return *((Vector2<T>*) elemRowCol[i]);
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) {
Vector2<T> operator [] (size_t i) {
tgtAssert(i < size, "i must be less than size");
return *((Vector2<T>*) elemRowCol[i]);
return Vector2<T>(elemRowCol[i]);
}
};
......@@ -361,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 {
Vector3<T> operator [] (size_t i) const {
tgtAssert(i < size, "i must be less than size");
return *((Vector3<T>*) elemRowCol[i]);
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) {
Vector3<T> operator [] (size_t i) {
tgtAssert(i < size, "i must be less than size");
return *((Vector3<T>*) elemRowCol[i]);
return Vector3<T>(elemRowCol[i]);
}
};
......@@ -630,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 {
Vector4<T> operator [] (size_t i) const {
tgtAssert(i < size, "i must be less than size");
return *((Vector4<T>*) elemRowCol[i]);
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) {
Vector4<T> operator [] (size_t i) {
tgtAssert(i < size, "i must be less than size");
return *((Vector4<T>*) elemRowCol[i]);
return Vector4<T>(elemRowCol[i]);
}
/**
......
......@@ -322,17 +322,17 @@ struct Vector3 {
/*
sub-vector getters
*/
const Vector2<T>& xy() const {
return *((Vector2<T>*) _xy);
Vector2<T> xy() const {
return Vector2<T>(_xy);
}
Vector2<T>& xy() {
return *((Vector2<T>*) _xy);
Vector2<T> xy() {
return Vector2<T>(_xy);
}
const Vector2<T>& yz() const {
return *((Vector2<T>*) (elem + 1));
Vector2<T> yz() const {
return Vector2<T>(elem + 1);
}
Vector2<T>& yz() {
return *((Vector2<T>*) (elem + 1));
Vector2<T> yz() {
return Vector2<T>(elem + 1);
}
/*
......@@ -467,35 +467,35 @@ struct Vector4 {
sub-vector getters
*/
const Vector2<T>& xy() const {
Vector2<T> xy() const {
return xyz().xy();
}
const Vector2<T>& yz() const {
return *((Vector2<T>*) (elem + 1));
Vector2<T> yz() const {
return Vector2<T>(elem + 1);
}
const Vector2<T>& zw() const {
return *((Vector2<T>*) (elem + 2));
Vector2<T> zw() const {
return Vector2<T>(elem + 2);
}
const Vector3<T>& xyz() const {
return *((Vector3<T>*) _xyz);
Vector3<T> xyz() const {
return Vector3<T>(_xyz);
}
const Vector3<T>& yzw() const {
return *((Vector3<T>*) (elem + 1));
Vector3<T> yzw() const {
return Vector3<T>(elem + 1);
}
Vector2<T>& xy() {
Vector2<T> xy() {
return xyz().xy();
}
Vector2<T>& yz() {
return *((Vector2<T>*) (elem + 1));
Vector2<T> yz() {
return Vector2<T>(elem + 1);
}
Vector2<T>& zw() {
return *((Vector2<T>*) (elem + 2));
Vector2<T> zw() {
return Vector2<T>(elem + 2);
}
Vector3<T>& xyz() {
return *((Vector3<T>*) _xyz);
Vector3<T> xyz() {
return Vector3<T>(_xyz);
}
Vector3<T>& yzw() {
return *((Vector3<T>*) (elem + 1));
Vector3<T> yzw() {
return Vector3<T>(elem + 1);
}
/*
......
......@@ -199,7 +199,6 @@ namespace campvis {
// update camera
tgt::Bounds volumeExtent = local->getParent()->getWorldBounds();
tgt::vec3 pos = volumeExtent.center() - tgt::vec3(0, 0, tgt::length(volumeExtent.diagonal()));
_trackballHandler->setSceneBounds(volumeExtent);
_trackballHandler->setCenter(volumeExtent.center());
......
......@@ -105,7 +105,6 @@ namespace campvis {
ScopedTypedData<RenderData> geometryImage(data, p_geometryImageId.getValue());
tgt::Bounds volumeExtent = img->getParent()->getWorldBounds();
tgt::Bounds textureBounds(tgt::vec3(0.f), tgt::vec3(1.f));
// clip proxy geometry against near-plane to support camera in volume
......
......@@ -75,9 +75,7 @@ namespace campvis {
if (tgt::sign(tgt::dot(cam.getLook(), n)) == 1)
n *= -1.f;
// TODO: the implicit GUI updates randomly crashes the applictation...
p_mirrorNormal.setValue(n);
std::vector<tgt::vec3> vertices;
tgt::vec3 temp = cam.getUpVector();
......@@ -85,7 +83,6 @@ namespace campvis {
temp = tgt::vec3(0.f, 1.f, 0.f);
tgt::vec3 inPlaneA = tgt::normalize(tgt::cross(n, temp)) * 0.5f * p_size.getValue();
tgt::vec3 inPlaneB = tgt::normalize(tgt::cross(n, inPlaneA)) * 0.5f * p_size.getValue();
const tgt::vec3& base = p_mirrorCenter.getValue();
......
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