MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / xLightKit_Prepare

Function xLightKit_Prepare

src/SB/Core/x/xLightKit.cpp:10–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8xLightKit* gLastLightKit;
9
10xLightKit* xLightKit_Prepare(void* data)
11{
12 xLightKit* lkit = (xLightKit*)data;
13 lkit->lightList = (xLightKitLight*)((int*)data + 4);
14 xLightKitLight* currlight = (xLightKitLight*)((int*)data + 4);
15
16 for (int i = 0; i < lkit->lightCount; currlight++, i++)
17 {
18 if (currlight->platLight != NULL)
19 {
20 return lkit;
21 }
22
23 // If any of the colors is greater than 1.0, normalize back to 0-1
24 if (currlight->color.red > 1.0f || currlight->color.green > 1.0f ||
25 currlight->color.blue > 1.0f)
26 {
27 F32 s;
28 s = MAX(MAX(currlight->color.red, currlight->color.green), currlight->color.blue);
29 s = MAX(s, 0.00001f);
30 s = 1.0f / s;
31 currlight->color.red *= s;
32 currlight->color.green *= s;
33 currlight->color.blue *= s;
34 }
35
36 switch (currlight->type)
37 {
38 case 1:
39 currlight->platLight = RpLightCreate(2);
40 break;
41 case 2:
42 currlight->platLight = RpLightCreate(1);
43 break;
44 case 3:
45 currlight->platLight = RpLightCreate(128);
46 break;
47 case 4:
48 currlight->platLight = RpLightCreate(130);
49 break;
50 default:
51 break;
52 }
53 RpLightSetColor(currlight->platLight, &currlight->color);
54 if (currlight->type >= 2)
55 {
56 RwFrame* frame = RwFrameCreate();
57 RwMatrixTag tmpmat;
58
59 memset(&tmpmat, 0, 64);
60 tmpmat.right.x = -currlight->matrix[0];
61 tmpmat.right.y = -currlight->matrix[1];
62 tmpmat.right.z = -currlight->matrix[2];
63 tmpmat.up.x = currlight->matrix[4];
64 tmpmat.up.y = currlight->matrix[5];
65 tmpmat.up.z = currlight->matrix[6];
66 tmpmat.at.x = -currlight->matrix[8];
67 tmpmat.at.y = -currlight->matrix[9];

Callers 2

zSceneInitFunction · 0.50
create_glow_lightFunction · 0.50

Calls 1

memsetFunction · 0.85

Tested by

no test coverage detected