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

Function CompLightCreate

engine/gamesys/src/gamesys/components/comp_light.cpp:73–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71 }
72
73 static dmGameObject::CreateResult CompLightCreate(const dmGameObject::ComponentCreateParams& params)
74 {
75 LightWorld* world = (LightWorld*) params.m_World;
76 LightContext* context = (LightContext*)params.m_Context;
77
78 if (world->m_Components.Full())
79 {
80 ShowFullBufferError("Light", LIGHT_MAX_COUNT_KEY, world->m_Components.Capacity());
81 return dmGameObject::CREATE_RESULT_UNKNOWN_ERROR;
82 }
83
84 LightComponent* light = new LightComponent;
85 memset(light, 0, sizeof(LightComponent));
86
87 light->m_Instance = params.m_Instance;
88 light->m_LightResource = (LightResource*) params.m_Resource;
89 light->m_LightInstance = dmRender::NewLightInstance(context->m_RenderContext, GetLightPrototype(light->m_LightResource));
90 if (light->m_LightInstance == 0)
91 {
92 ShowFullBufferError("Light", LIGHT_MAX_COUNT_KEY, (int) context->m_MaxLightCount);
93 delete light;
94 return dmGameObject::CREATE_RESULT_UNKNOWN_ERROR;
95 }
96
97 world->m_Components.Push(light);
98 *params.m_UserData = (uintptr_t) light;
99 return dmGameObject::CREATE_RESULT_OK;
100 }
101
102 static void* CompLightGetComponent(const dmGameObject::ComponentGetParams& params)
103 {

Callers

nothing calls this directly

Calls 6

ShowFullBufferErrorFunction · 0.85
NewLightInstanceFunction · 0.85
GetLightPrototypeFunction · 0.85
FullMethod · 0.45
CapacityMethod · 0.45
PushMethod · 0.45

Tested by

no test coverage detected