The doubt in BatchQueue::SortFrontToBack2Pass

I think that there is an error in this function at line 842 in Batch.cpp, where it remaps the material IDs in the sort key:
unsigned short materialID = (unsigned short)(batch->sortKey_ & 0xffff0000);.
The materialID is always 0 no matter what sortKey_ value.
Because the data type of sortKey_ is unsigned long long.
when (unsigned short) unsigned long long, it will get the value in low 16 bit, that is 0.

I make the following modification.
unsigned short materialID = (unsigned short)((batch->sortKey_ & 0xffff0000) >> 16);
the materialID will get the correct value and the function will go correct.

Welcome discussion.

It seems right to me.

Looks like a bug. There should be a shift of 16 bits to the right.