| 632 | static_assert(sizeof(PackedSortKeyDistance) == sizeof(uint64), "Invalid sort key size"); |
| 633 | |
| 634 | FORCE_INLINE void CalculateSortKey(const RenderContext& renderContext, DrawCall& drawCall, int8 sortOrder) |
| 635 | { |
| 636 | const Float3 planeNormal = renderContext.View.Direction; |
| 637 | const float planePoint = -Float3::Dot(planeNormal, renderContext.View.Position); |
| 638 | const float distance = Float3::Dot(planeNormal, drawCall.ObjectPosition) - planePoint; |
| 639 | uint32 distanceKey = RenderTools::ComputeDistanceSortKey(distance); |
| 640 | uint32 batchKey = GetHash(drawCall.Material); |
| 641 | IMaterial::InstancingHandler handler; |
| 642 | if (drawCall.Material->CanUseInstancing(handler)) |
| 643 | handler.GetHash(drawCall, batchKey); |
| 644 | batchKey = (batchKey * 397) ^ drawCall.StencilValue; |
| 645 | uint32 drawKey = (uint32)(471 * drawCall.WorldDeterminant); |
| 646 | drawKey = (drawKey * 397) ^ GetHash(drawCall.Geometry.VertexBuffers[0]); |
| 647 | drawKey = (drawKey * 397) ^ GetHash(drawCall.Geometry.VertexBuffers[1]); |
| 648 | drawKey = (drawKey * 397) ^ GetHash(drawCall.Geometry.VertexBuffers[2]); |
| 649 | drawKey = (drawKey * 397) ^ GetHash(drawCall.Geometry.IndexBuffer); |
| 650 | |
| 651 | PackedSortKey key; |
| 652 | key.BatchKey = (uint16)batchKey; |
| 653 | key.DistanceKey = distanceKey; |
| 654 | key.DrawKey = (uint8)drawKey; |
| 655 | key.SortKey = (uint8)(sortOrder - MIN_int8); |
| 656 | drawCall.SortKey = *(uint64*)&key; |
| 657 | } |
| 658 | |
| 659 | void RenderList::AddDrawCall(const RenderContext& renderContext, DrawPass drawModes, StaticFlags staticFlags, DrawCall& drawCall, bool receivesDecals, int8 sortOrder) |
| 660 | { |
no test coverage detected