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

Method AddDynamicSpotLight

TombEngine/Renderer/RendererDraw.cpp:1612–1647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1610 }
1611
1612 void Renderer::AddDynamicSpotLight(const Vector3& pos, const Vector3& dir, float radius, float falloff, float distance, const Color& color, bool castShadows, int hash)
1613 {
1614 if (_isLocked || g_GameFlow->LastFreezeMode != FreezeMode::None)
1615 return;
1616
1617 RendererLight dynamicLight = {};
1618
1619 dynamicLight.Color = Vector3(color.x, color.y, color.z);
1620 if (falloff < 8)
1621 dynamicLight.Color *= (falloff / 8.0f);
1622
1623 // Calculate outer cone angle (degrees) based on radius at the cone's end distance.
1624 float outerConeAngle = atan(radius / distance) * (180.0f / PI);
1625 float innerConeAngle = atan((radius - falloff) / distance) * (180.0f / PI);
1626 float innerDistance = std::max(0.0f, distance - distance * (falloff / radius));
1627
1628 // Normalize direction for safety.
1629 auto normalizedDirection = dir;
1630 normalizedDirection.Normalize();
1631
1632 dynamicLight.RoomNumber = NO_VALUE;
1633 dynamicLight.Intensity = 1.0f;
1634 dynamicLight.Position = pos;
1635 dynamicLight.Direction = normalizedDirection;
1636 dynamicLight.In = innerDistance;
1637 dynamicLight.Out = distance;
1638 dynamicLight.InRange = innerConeAngle > 0.0f ? innerConeAngle : 0.5f;
1639 dynamicLight.OutRange = outerConeAngle;
1640 dynamicLight.Type = LightType::Spot;
1641 dynamicLight.CastShadows = castShadows;
1642 dynamicLight.BoundingSphere = BoundingSphere(pos, distance);
1643 dynamicLight.Luma = Luma(dynamicLight.Color);
1644 dynamicLight.Hash = hash;
1645
1646 PrepareDynamicLight(dynamicLight);
1647 }
1648
1649 void Renderer::AddDynamicPointLight(const Vector3& pos, float radius, const Color& color, bool castShadows, int hash)
1650 {

Callers 1

SpawnDynamicSpotLightFunction · 0.80

Calls 3

LumaFunction · 0.85
Vector3Function · 0.50
NormalizeMethod · 0.45

Tested by

no test coverage detected