In the cube class I have its position and rotation. Also I have a collision check function:
bool is_collision(voxel collis)
{
if (collis.position.x > position.x || collis.position.y > position.y || collis.position.z > position.z)
{
if (collis.position.x - position.x <= 1 && collis.position.y - position.y <= 1 && collis.position.z - position.z <= 1)
{
return true;
}
}
else if (collis.position.x < position.x || collis.position.y < position.y || collis.position.z < position.z)
{
if (position.x - collis.position.x <= 1 && position.y - collis.position.y <= 1 && position.z - collis.position.z <= 1)
{
return true;
}
}
return false;
}
It accepts another cube to be collided with. But so far, this function does not take into account the rotation of the object. I also use glm. How do I need to change this code?