MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / DrawStaticSorted

Method DrawStaticSorted

TombEngine/Renderer/RendererDraw.cpp:3892–3930  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3890 }
3891
3892 void Renderer::DrawStaticSorted(RendererSortableObject* objectInfo, RendererObjectType lastObjectType, RenderView& view)
3893 {
3894 if (lastObjectType != objectInfo->ObjectType)
3895 {
3896 unsigned int stride = sizeof(Vertex);
3897 unsigned int offset = 0;
3898 _context->IASetVertexBuffers(0, 1, _staticsVertexBuffer.Buffer.GetAddressOf(), &stride, &offset);
3899 _context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
3900 _context->IASetInputLayout(_inputLayout.Get());
3901
3902 SetDepthState(DepthState::Read);
3903 SetCullMode(CullMode::CounterClockwise);
3904
3905 _shaders.Bind(Shader::InstancedStatics);
3906 }
3907
3908 _sortedPolygonsIndexBuffer.Update(_context.Get(), _sortedPolygonsIndices, 0, (int)_sortedPolygonsIndices.size());
3909 _context->IASetIndexBuffer(_sortedPolygonsIndexBuffer.Buffer.Get(), DXGI_FORMAT_R32_UINT, 0);
3910
3911 auto world = objectInfo->Static->World;
3912 _stInstancedStaticMeshBuffer.StaticMeshes[0].World = world;
3913
3914 _stInstancedStaticMeshBuffer.StaticMeshes[0].Color = objectInfo->Static->Color;
3915 _stInstancedStaticMeshBuffer.StaticMeshes[0].Ambient = objectInfo->Room->AmbientLight;
3916 _stInstancedStaticMeshBuffer.StaticMeshes[0].LightMode = (int)GetStaticRendererObject(objectInfo->Static->ObjectNumber).ObjectMeshes[0]->LightMode;
3917 BindInstancedStaticLights(objectInfo->Static->LightsToDraw, 0);
3918 UpdateConstantBuffer(_stInstancedStaticMeshBuffer, _cbInstancedStaticMeshBuffer);
3919
3920 SetBlendMode(objectInfo->BlendMode);
3921 SetAlphaTest(AlphaTestMode::None, ALPHA_TEST_THRESHOLD);
3922
3923 BindBucketTextures(*objectInfo->Bucket, TextureSource::Statics, objectInfo->Bucket->Animated);
3924 BindMaterial(objectInfo->Bucket->MaterialIndex, false);
3925
3926 DrawIndexedInstancedTriangles((int)_sortedPolygonsIndices.size(), 1, 0, 0);
3927
3928 _numSortedStaticsDrawCalls++;
3929 _numSortedTriangles += (int)_sortedPolygonsIndices.size() / 3;
3930 }
3931
3932 void Renderer::DrawMoveableAsStaticSorted(RendererSortableObject* objectInfo, RendererObjectType lastObjectType, RenderView& view)
3933 {

Callers

nothing calls this directly

Calls 5

GetAddressOfMethod · 0.80
BindMethod · 0.80
GetMethod · 0.45
UpdateMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected