| 3787 | } |
| 3788 | |
| 3789 | void Renderer::DrawRoomSorted(RendererSortableObject* objectInfo, RendererObjectType lastObjectType, RenderView& view) |
| 3790 | { |
| 3791 | if (lastObjectType != objectInfo->ObjectType) |
| 3792 | { |
| 3793 | unsigned int stride = sizeof(Vertex); |
| 3794 | unsigned int offset = 0; |
| 3795 | _context->IASetVertexBuffers(0, 1, _roomsVertexBuffer.Buffer.GetAddressOf(), &stride, &offset); |
| 3796 | _context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); |
| 3797 | _context->IASetInputLayout(_inputLayout.Get()); |
| 3798 | |
| 3799 | SetDepthState(DepthState::Read); |
| 3800 | SetCullMode(CullMode::CounterClockwise); |
| 3801 | |
| 3802 | _shaders.Bind(Shader::Rooms); |
| 3803 | } |
| 3804 | |
| 3805 | _sortedPolygonsIndexBuffer.Update(_context.Get(), _sortedPolygonsIndices, 0, (int)_sortedPolygonsIndices.size()); |
| 3806 | _context->IASetIndexBuffer(_sortedPolygonsIndexBuffer.Buffer.Get(), DXGI_FORMAT_R32_UINT, 0); |
| 3807 | |
| 3808 | RoomData* nativeRoom = &g_Level.Rooms[objectInfo->Room->RoomNumber]; |
| 3809 | |
| 3810 | _stRoom.Caustics = int(g_Configuration.EnableCaustics && (nativeRoom->flags & ENV_FLAG_WATER) && !(nativeRoom->flags & ENV_FLAG_NOCAUSTICS)); |
| 3811 | _stRoom.AmbientColor = Vector3(objectInfo->Room->AmbientLight.x, objectInfo->Room->AmbientLight.y, objectInfo->Room->AmbientLight.z); |
| 3812 | BindRoomLights(view.LightsToDraw); |
| 3813 | _stRoom.NumRoomDecals = 0; // Don't draw decals on sorted faces to avoid slowdowns. |
| 3814 | _stRoom.Water = (nativeRoom->flags & ENV_FLAG_WATER) != 0 ? 1 : 0; |
| 3815 | UpdateConstantBuffer(_stRoom, _cbRoom); |
| 3816 | |
| 3817 | SetScissor(objectInfo->Room->ClipBounds); |
| 3818 | |
| 3819 | SetBlendMode(objectInfo->BlendMode); |
| 3820 | SetAlphaTest(AlphaTestMode::None, ALPHA_TEST_THRESHOLD); |
| 3821 | |
| 3822 | BindBucketTextures(*objectInfo->Bucket, TextureSource::Rooms, objectInfo->Bucket->Animated); |
| 3823 | BindMaterial(objectInfo->Bucket->MaterialIndex, false); |
| 3824 | |
| 3825 | DrawIndexedTriangles((int)_sortedPolygonsIndices.size(), 0, 0); |
| 3826 | |
| 3827 | _numSortedRoomsDrawCalls++; |
| 3828 | _numSortedTriangles += (int)_sortedPolygonsIndices.size() / 3; |
| 3829 | |
| 3830 | ResetScissor(); |
| 3831 | } |
| 3832 | |
| 3833 | void Renderer::DrawItemSorted(RendererSortableObject* objectInfo, RendererObjectType lastObjectType, RenderView& view) |
| 3834 | { |