 
 		// Convert to gpu bvh tree nodes.
 		{
-			numOfElems = numInternalNode + numLeaves;
+			const auto numOfElems = numInternalNode + numLeaves;
 
 			dim3 block(128, 1, 1);
 			dim3 grid((numOfElems + block.x - 1) / block.x, 1, 1);

	if (key1 == key2)
	{

		return 32 + __clz(index1 ^ index2);
	}

	auto ret = __clz(key1 ^ key2);

	return ret;
}


		// Radix sort.
		m_sort.sort(
			numberOfTris,
			m_mortonCodes,
			m_indices,
			m_sortedMortonCode,
			m_sortedIndices);

		uint32_t numInternalNode = numberOfTris - 1;
		uint32_t numLeaves = numberOfTris;

		// Build tree.
		{
			dim3 block(256, 1, 1);
			dim3 grid((numberOfTris + block.x - 1) / block.x, 1, 1);

			buildTree << <grid, block >> > (
				numberOfTris,
				m_sortedMortonCode.ptr(),
				m_nodesLbvh.ptr());

