Hello,
so I have an int64 as a "sort key", where I set specific bits to group my render calls into e.g. materials from bit 34 to bit 48. Now I wonder, what was an optimized way to set all bits in this range? Seems my bit-math is still a bit off, I can't think of any of the standard opertations to perform this. I could bitshift every single bit from my material id, and then eigther set or unset the respective bit in the sort-key, but there's gotta be a better way to replace all bits from X to Y in an int64 with the respective bits of another int64. Right?
void Model::SetMaterial(unsigned int id)
{
//that does only set the bit, but what about already set ones that should be overwritten?
//plus, it would overide all bits up to #64, but we only want this to be up to #48
m_sortKey |= ((unsigned __int64)(m_pMaterial->m_id) << 34);
}