Tag Info

New answers tagged

0

You could use an user-defined conversion, something like this: struct GpuVec3 { public: GpuVec3() {} GpuVec3& GpuVec3::operator=(const vec3& other) { v.x = other.x; v.y = other.y; v.z = other.z; v.w = 1.0f; return *this; } operator glm::vec3() const { return v.xyz; } private: vec4 ...


1

I think you would do to keep your GPUVec3 and your vec3 as two separate classes, not one containing the other. Here's an example: struct vec3 { float x,y,z; }; struct GPUVec3 { float x,y,z, pad; GPUVec3() { } GPUVec3( float x, float y, float z ) { } GPUVec3( const vec3 & v ) { } operator vec3 const & () const { return ...


1

I assume your world is represented as a grid, the algorithm you need to do line grid intersection is called Digital differential analyzer algorithm. The code too much to write quickly, you can find a full explanation here. This algorithm/technique is used to solve different problems that need interpolating a variable over an interval. It's similar to ...



Top 50 recent answers are included