summaryrefslogtreecommitdiff
path: root/src/common.cuh
diff options
context:
space:
mode:
authorbrett weiland <brettsweiland@gmail.com>2024-06-01 01:36:18 -0500
committerbrett weiland <brettsweiland@gmail.com>2024-06-01 01:36:18 -0500
commitb0dd97ee6bf8d5daa587da40ad941efac68152df (patch)
treef162d32767e0b0f84bed284f6e8ab2c5309ff248 /src/common.cuh
parent093200a449ea38952de52012e324036c106e294b (diff)
got raycasting laid out
Diffstat (limited to 'src/common.cuh')
-rw-r--r--src/common.cuh53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/common.cuh b/src/common.cuh
new file mode 100644
index 0000000..9e026f4
--- /dev/null
+++ b/src/common.cuh
@@ -0,0 +1,53 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+#include "include/helper_math.h"
+
+/**
+
+template <class T> class vect_t2;
+template <class T> class vect3;
+template <class T> class vect_t4;
+
+//this feels so hacky... idk why people are so scared of metaprogramming
+template <> class vect_t2<double> { public: using vect_t = double2; };
+template <> class vect3<double> { public: using vect_t = double3; };
+template <> class vect_t4<double> { public: using vect_t = double4; };
+
+template <> class vect_t2<float> { public: using vect_t = float2; };
+template <> class vect3<float> { public: using vect_t = float3; };
+template <> class vect_t4<float> { public: using vect_t = float4; };
+
+
+template <class T, class X> __device__ T vect_create(X x);
+template <class T, class X, class Y, class Z> __device__ T vect_create(X x, Y y, Z z);
+
+//I have no fucking clue if this is right, check me later ig
+template <class float3, class X> __device__ inline float3 vect_create<float3>(X x) { return make_float3(x); }
+
+template <class float3, class X, class Y, class Z> __device__ inline float3 vect_create<float3>(X x, Y y, Z z) { return make_float3(x, y, z); }
+**/
+
+/** I'm not sure weather float or double percision is nessesary. I was using
+templates, but this changes the structure of my entire project in unwanted
+ways, so I'm switching over to typedefs. **/
+
+typedef float2 vect2;
+typedef float3 vect3;
+typedef float T;
+
+#define make_vect3(...) (make_float3(__VA_ARGS__))
+
+//TODO move to color.cuh
+typedef float3 Color;
+#define make_color(...) (make_float3(__VA_ARGS__))
+
+//TODO move to ray.cuh
+struct Ray {
+ Color color;
+ vect3 start;
+ vect3 direction; //MUST BE A UNIT VECTOR
+ int bounces;
+};
+
+#endif