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

Function NewLightInstance

engine/render/src/render/light.cpp:70–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68 ////////////////////////////////
69
70 HLightInstance NewLightInstance(HRenderContext render_context, HLightPrototype light_prototype)
71 {
72 // Reached max count.
73 if (render_context->m_RenderLightsIndices.Remaining() == 0)
74 {
75 return 0;
76 }
77
78 if (render_context->m_RenderLights.Full())
79 {
80 render_context->m_RenderLights.Allocate(32);
81 }
82
83 LightInstance* light_instance = new LightInstance;
84 light_instance->m_Position = dmVMath::Point3(0.0f, 0.0f, 0.0f);
85 light_instance->m_Direction = light_prototype->m_Direction;
86 light_instance->m_LightPrototype = light_prototype;
87 light_instance->m_LightBufferIndex = render_context->m_RenderLightsIndices.Pop();
88
89 if (light_instance->m_LightBufferIndex >= render_context->m_LightBufferScratch.Size())
90 {
91 render_context->m_LightBufferScratch.SetSize(light_instance->m_LightBufferIndex+1);
92 }
93
94 CommitLightInstance(render_context, light_instance);
95 CommitLightCount(render_context);
96
97 return render_context->m_RenderLights.Put(light_instance);
98 }
99
100 void DeleteLightInstance(HRenderContext render_context, HLightInstance instance)
101 {

Callers 2

TEST_FFunction · 0.85
CompLightCreateFunction · 0.85

Calls 10

CommitLightInstanceFunction · 0.85
CommitLightCountFunction · 0.85
Point3Class · 0.50
RemainingMethod · 0.45
FullMethod · 0.45
AllocateMethod · 0.45
PopMethod · 0.45
SizeMethod · 0.45
SetSizeMethod · 0.45
PutMethod · 0.45

Tested by 1

TEST_FFunction · 0.68