| 277 | } |
| 278 | |
| 279 | void Renderer::DrawGunShells(RenderView& view, RendererPass rendererPass) |
| 280 | { |
| 281 | auto& room = _rooms[LaraItem->RoomNumber]; |
| 282 | auto* item = &_items[LaraItem->Index]; |
| 283 | |
| 284 | int gunShellCount = 0; |
| 285 | int objectID = 0; |
| 286 | |
| 287 | for (int i = 0; i < MAX_GUNSHELL; i++) |
| 288 | { |
| 289 | auto* gunshell = &Gunshells[i]; |
| 290 | |
| 291 | if (gunshell->counter <= 0) |
| 292 | continue; |
| 293 | |
| 294 | if (IgnoreReflectionPassForRoom(gunshell->roomNumber)) |
| 295 | continue; |
| 296 | |
| 297 | objectID = gunshell->objectNumber; |
| 298 | |
| 299 | if (!_moveableObjects[objectID].has_value()) |
| 300 | continue; |
| 301 | |
| 302 | auto translation = Matrix::CreateTranslation(gunshell->pos.Position.ToVector3()); |
| 303 | auto rotMatrix = gunshell->pos.Orientation.ToRotationMatrix(); |
| 304 | auto worldMatrix = rotMatrix * translation; |
| 305 | |
| 306 | auto prevTranslation = Matrix::CreateTranslation( |
| 307 | gunshell->PrevPose.Position.x, |
| 308 | gunshell->PrevPose.Position.y, |
| 309 | gunshell->PrevPose.Position.z); |
| 310 | auto prevRotMatrix = gunshell->PrevPose.Orientation.ToRotationMatrix(); |
| 311 | auto prevWorldMatrix = prevRotMatrix * prevTranslation; |
| 312 | |
| 313 | worldMatrix = Matrix::Lerp(prevWorldMatrix, worldMatrix, GetInterpolationFactor()); |
| 314 | ReflectMatrixOptionally(worldMatrix); |
| 315 | |
| 316 | _stInstancedStaticMeshBuffer.StaticMeshes[gunShellCount].World = worldMatrix; |
| 317 | _stInstancedStaticMeshBuffer.StaticMeshes[gunShellCount].Ambient = room.AmbientLight; |
| 318 | _stInstancedStaticMeshBuffer.StaticMeshes[gunShellCount].Color = room.AmbientLight; |
| 319 | _stInstancedStaticMeshBuffer.StaticMeshes[gunShellCount].LightMode = (int)LightMode::Dynamic; |
| 320 | BindInstancedStaticLights(item->LightsToDraw, gunShellCount); |
| 321 | |
| 322 | gunShellCount++; |
| 323 | } |
| 324 | |
| 325 | if (gunShellCount > 0) |
| 326 | { |
| 327 | auto& moveableObject = *_moveableObjects[objectID]; |
| 328 | |
| 329 | _shaders.Bind(Shader::InstancedStatics); |
| 330 | |
| 331 | unsigned int stride = sizeof(Vertex); |
| 332 | unsigned int offset = 0; |
| 333 | _context->IASetVertexBuffers(0, 1, _moveablesVertexBuffer.Buffer.GetAddressOf(), &stride, &offset); |
| 334 | _context->IASetIndexBuffer(_moveablesIndexBuffer.Buffer.Get(), DXGI_FORMAT_R32_UINT, 0); |
| 335 | |
| 336 | SetBlendMode(BlendMode::Opaque); |
nothing calls this directly
no test coverage detected