Fix platform/VecTypes.hpp & platform/types/vec{2,3,3}.hpp

master
Dorian Wouters 2017-03-16 13:31:39 -04:00
parent 710ff2537f
commit 6d4b28688a
No known key found for this signature in database
GPG Key ID: 6E9DA8063322434B
6 changed files with 24 additions and 80 deletions

View File

@ -4,14 +4,14 @@
namespace Diggler {
void Frustum::setCamInternals(vec3ct rad, vec3ct ratio, vec3ct nearD, vec3ct farD) {
void Frustum::setCamInternals(vec3vt rad, vec3vt ratio, vec3vt nearD, vec3vt farD) {
this->ratio = ratio;
this->angle = rad;
this->nearD = nearD;
this->farD = farD;
// Compute ALL the things
tang = std::tan(rad * static_cast<vec3ct>(.5));
tang = std::tan(rad * static_cast<vec3vt>(.5));
nh = nearD * tang;
nw = nh * ratio;
fh = farD * tang;
@ -53,13 +53,13 @@ void Frustum::setCamDef(const vec3 &p, const vec3 &l, const vec3 &u) {
bool Frustum::pointInFrustum(const vec3& p) const {
for(int i=0; i < 6; i++) {
if (pl[i].distance(p) < static_cast<vec3ct>(0))
if (pl[i].distance(p) < static_cast<vec3vt>(0))
return false;
}
return true;
}
bool Frustum::sphereInFrustum(const vec3 &p, vec3ct radius) const {
bool Frustum::sphereInFrustum(const vec3 &p, vec3vt radius) const {
for(int i=0; i < 6; i++) {
if (pl[i].distance(p) < -radius)
return false;

View File

@ -18,7 +18,7 @@ public:
class Plane {
public:
vec3 normal;
vec3ct d;
vec3vt d;
Plane(const vec3 &v1, const vec3 &v2, const vec3 &v3) {
set3Points(v1, v2, v3);
@ -35,27 +35,27 @@ public:
this->normal = glm::normalize(normal);
d = -glm::dot(normal, point);
}
void setCoefficients(vec3ct a, vec3ct b, vec3ct c, vec3ct d) {
void setCoefficients(vec3vt a, vec3vt b, vec3vt c, vec3vt d) {
normal = vec3(a, b, c);
vec3ct l = glm::length(normal);
vec3vt l = glm::length(normal);
normal /= l; // normalizes
this->d = d / l;
}
vec3ct distance(const vec3 &p) const {
vec3vt distance(const vec3 &p) const {
return (d + glm::dot(normal, p));
}
} pl[6];
vec3 ntl,ntr,nbl,nbr,ftl,ftr,fbl,fbr;
vec3ct nearD, farD, ratio, angle,tang;
vec3ct nw,nh,fw,fh;
vec3vt nearD, farD, ratio, angle,tang;
vec3vt nw,nh,fw,fh;
Frustum() = default;
~Frustum() = default;
void setCamInternals(vec3ct rad, vec3ct ratio, vec3ct nearD, vec3ct farD);
void setCamInternals(vec3vt rad, vec3vt ratio, vec3vt nearD, vec3vt farD);
void setCamDef(const vec3 &p, const vec3 &l, const vec3 &u);
bool pointInFrustum(const vec3 &p) const;
bool sphereInFrustum(const vec3 &p, vec3ct radius) const;
bool sphereInFrustum(const vec3 &p, vec3vt radius) const;
//bool boxInFrustum(const AABB &b) const;
};

View File

@ -1,64 +1,8 @@
#ifndef DIGGLER_PLATFORM_VEC_TYPES_HPP
#define DIGGLER_PLATFORM_VEC_TYPES_HPP
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include "Types.hpp"
namespace Diggler {
using vec2u8 = glm::tvec2<uint8, glm::defaultp>;
using vec2u16 = glm::tvec2<uint16, glm::defaultp>;
using vec2u32 = glm::tvec2<uint32, glm::defaultp>;
using vec2u64 = glm::tvec2<uint64, glm::defaultp>;
using vec2u = vec2u64;
using vec2i8 = glm::tvec2<int8, glm::defaultp>;
using vec2i16 = glm::tvec2<int16, glm::defaultp>;
using vec2i32 = glm::tvec2<int32, glm::defaultp>;
using vec2i64 = glm::tvec2<int64, glm::defaultp>;
using vec2i = vec2i64;
using vec2f = glm::tvec2<float, glm::defaultp>;
using vec2d = glm::tvec2<double, glm::defaultp>;
using vec2 = vec2d;
using vec3u8 = glm::tvec3<uint8, glm::defaultp>;
using vec3u16 = glm::tvec3<uint16, glm::defaultp>;
using vec3u32 = glm::tvec3<uint32, glm::defaultp>;
using vec3u64 = glm::tvec3<uint64, glm::defaultp>;
using vec3u = vec3u64;
using vec3i8 = glm::tvec3<int8, glm::defaultp>;
using vec3i16 = glm::tvec3<int16, glm::defaultp>;
using vec3i32 = glm::tvec3<int32, glm::defaultp>;
using vec3i64 = glm::tvec3<int64, glm::defaultp>;
using vec3i = vec3i64;
using vec3f = glm::tvec3<float, glm::defaultp>;
using vec3d = glm::tvec3<double, glm::defaultp>;
using vec3 = vec3d;
using vec4u8 = glm::tvec4<uint8, glm::defaultp>;
using vec4u16 = glm::tvec4<uint16, glm::defaultp>;
using vec4u32 = glm::tvec4<uint32, glm::defaultp>;
using vec4u64 = glm::tvec4<uint64, glm::defaultp>;
using vec4u = vec4u64;
using vec4i8 = glm::tvec4<int8, glm::defaultp>;
using vec4i16 = glm::tvec4<int16, glm::defaultp>;
using vec4i32 = glm::tvec4<int32, glm::defaultp>;
using vec4i64 = glm::tvec4<int64, glm::defaultp>;
using vec4i = vec4i64;
using vec4f = glm::tvec4<float, glm::defaultp>;
using vec4d = glm::tvec4<double, glm::defaultp>;
using vec4 = vec4d;
}
#include "types/vec2.hpp"
#include "types/vec3.hpp"
#include "types/vec4.hpp"
#endif /* DIGGLER_PLATFORM_VEC_TYPES_HPP */

View File

@ -12,19 +12,19 @@ using vec2u16 = glm::tvec2<uint16>;
using vec2u32 = glm::tvec2<uint32>;
using vec2u64 = glm::tvec2<uint64>;
using vec2u = vec2u64;
using vec2uct = vec2u::value_type;
using vec2uvt = vec2u::value_type;
using vec2i8 = glm::tvec2<int8>;
using vec2i16 = glm::tvec2<int16>;
using vec2i32 = glm::tvec2<int32>;
using vec2i64 = glm::tvec2<int64>;
using vec2i = vec2i64;
using vec2ict = vec2i::value_type;
using vec2ivt = vec2i::value_type;
using vec2f = glm::tvec2<float>;
using vec2d = glm::tvec2<double>;
using vec2 = vec2d;
using vec2ct = vec2::value_type;
using vec2vt = vec2::value_type;
}

View File

@ -12,19 +12,19 @@ using vec3u16 = glm::tvec3<uint16>;
using vec3u32 = glm::tvec3<uint32>;
using vec3u64 = glm::tvec3<uint64>;
using vec3u = vec3u64;
using vec3tct = vec3u::value_type;
using vec3uvt = vec3u::value_type;
using vec3i8 = glm::tvec3<int8>;
using vec3i16 = glm::tvec3<int16>;
using vec3i32 = glm::tvec3<int32>;
using vec3i64 = glm::tvec3<int64>;
using vec3i = vec3i64;
using vec3ict = vec3i::value_type;
using vec3ivt = vec3i::value_type;
using vec3f = glm::tvec3<float>;
using vec3d = glm::tvec3<double>;
using vec3 = vec3d;
using vec3ct = vec3::value_type;
using vec3vt = vec3::value_type;
}

View File

@ -12,19 +12,19 @@ using vec4u16 = glm::tvec4<uint16>;
using vec4u32 = glm::tvec4<uint32>;
using vec4u64 = glm::tvec4<uint64>;
using vec4u = vec4u64;
using vec4uct = vec4u::value_type;
using vec4uvt = vec4u::value_type;
using vec4i8 = glm::tvec4<int8>;
using vec4i16 = glm::tvec4<int16>;
using vec4i32 = glm::tvec4<int32>;
using vec4i64 = glm::tvec4<int64>;
using vec4i = vec4i64;
using vec4ict = vec4i::value_type;
using vec4ivt = vec4i::value_type;
using vec4f = glm::tvec4<float>;
using vec4d = glm::tvec4<double>;
using vec4 = vec4d;
using vec4ct = vec4::value_type;
using vec4vt = vec4::value_type;
}