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

Method PrepareDynamicLight

TombEngine/Renderer/RendererDraw.cpp:1700–1746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1698 }
1699
1700 void Renderer::PrepareDynamicLight(RendererLight& light)
1701 {
1702 // If hash is provided, search for same light in previous buffer.
1703 if (light.Hash != 0)
1704 {
1705 // Determine previous buffer index.
1706 const auto& prevList = _dynamicLights[1 - _dynamicLightList];
1707
1708 // Find light in previous buffer with same hash.
1709 auto it = std::find_if(
1710 prevList.begin(), prevList.end(),
1711 [&light](const auto& prevLight)
1712 {
1713 return (prevLight.Hash == light.Hash);
1714 });
1715
1716 if (it != prevList.end())
1717 {
1718 // If matching light is found, copy it.
1719 const auto& prevLight = *it;
1720 light.PrevPosition = prevLight.Position;
1721 light.PrevDirection = prevLight.Direction;
1722 }
1723 }
1724
1725 // Queue dynamic light.
1726 _dynamicLights[_dynamicLightList].push_back(light);
1727
1728 // Check if light is spawned in mirrored room and create reflection.
1729 for (const auto& mirror : g_Level.Mirrors)
1730 {
1731 if (!mirror.ReflectLights)
1732 continue;
1733
1734 // TODO: Avoid LaraItem global.
1735 if ((Camera.pos.RoomNumber == mirror.RoomNumber || LaraItem->RoomNumber == mirror.RoomNumber) &&
1736 IsPointInRoom(light.Position, mirror.RoomNumber))
1737 {
1738 auto reflectedLight = light;
1739 reflectedLight.Position = Vector3::Transform(light.Position, mirror.ReflectionMatrix);
1740 reflectedLight.Direction = Vector3::Transform(light.Direction, mirror.ReflectionMatrix);
1741 reflectedLight.Hash = 0;
1742
1743 _dynamicLights[_dynamicLightList].push_back(reflectedLight);
1744 }
1745 }
1746 }
1747
1748 void Renderer::PrepareScene()
1749 {

Callers

nothing calls this directly

Calls 4

IsPointInRoomFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected