MCPcopy Create free account
hub / github.com/defold/defold / CommitLightInstance

Function CommitLightInstance

engine/render/src/render/light.cpp:231–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229 }
230
231 static inline void CommitLightInstance(HRenderContext render_context, LightInstance* instance)
232 {
233 const LightPrototype* prototype = instance->m_LightPrototype;
234
235 LightSTD140& light_std140 = render_context->m_LightBufferScratch[instance->m_LightBufferIndex];
236 light_std140.m_Position = dmVMath::Vector4(instance->m_Position);
237 light_std140.m_Color = prototype->m_Color;
238
239 dmVMath::Vector3 direction(0.0f, 0.0f, 0.0f);
240 float range = 0.0f;
241 float inner_cone = 0.0f;
242 float outer_cone = 0.0f;
243
244 switch (prototype->m_Type)
245 {
246 case LIGHT_TYPE_DIRECTIONAL:
247 direction = instance->m_Direction;
248 break;
249 case LIGHT_TYPE_POINT:
250 range = prototype->m_Range;
251 break;
252 case LIGHT_TYPE_SPOT:
253 direction = instance->m_Direction;
254 range = prototype->m_Range;
255 inner_cone = prototype->m_InnerConeAngle;
256 outer_cone = prototype->m_OuterConeAngle;
257 break;
258 default:
259 assert("Light type not supported!");
260 break;
261 }
262
263 light_std140.m_DirectionRange = dmVMath::Vector4(direction, range);
264 light_std140.m_Params = dmVMath::Vector4((float) prototype->m_Type, prototype->m_Intensity, inner_cone, outer_cone);
265
266 // Mark dirty range
267 render_context->m_LightBufferDirtyStart = dmMath::Min(render_context->m_LightBufferDirtyStart, (uint32_t) instance->m_LightBufferIndex);
268 render_context->m_LightBufferDirtyEnd = dmMath::Max(render_context->m_LightBufferDirtyEnd, (uint32_t) (instance->m_LightBufferIndex + 1));
269 }
270
271 static inline void CommitLightCount(HRenderContext render_context)
272 {

Callers 2

NewLightInstanceFunction · 0.85
SetLightInstanceFunction · 0.85

Calls 4

MinFunction · 0.85
Vector4Class · 0.50
assertFunction · 0.50
MaxFunction · 0.50

Tested by

no test coverage detected