blob: 90a495607ecf5b18c77fbf4412606323e3a3fc71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include "nw4r/g3d.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
namespace {
inline void SetBind(u16 *pId, u32 id) {
*pId = id;
}
inline bool IsBound(const u16 *pId) {
return *pId != ResLightSetData::INVALID_ID;
}
} // namespace
bool ResLightSet::Bind(const ResAnmScn scene) {
ResLightSetData &r = ref();
int numAllLight = 0;
int numBound = 0;
if (HasAmbLight() && scene.HasResAnmAmbLight()) {
numAllLight++;
if (!IsAmbLightBound()) {
ResName name = GetAmbLightResName();
ResAnmAmbLight light = scene.GetResAnmAmbLight(name);
if (light.IsValid()) {
SetBind(&r.ambLightId, light.GetID());
numBound++;
}
} else {
numBound++;
}
}
if (scene.HasResAnmLight()) {
u32 numLight = GetNumLight();
numAllLight += numLight;
for (u32 i = 0; i < numLight; i++) {
u16 *pId = &r.lightId[i];
if (IsBound(pId)) {
numBound++;
continue;
}
ResName name = GetLightResName(i);
ResAnmLight light = scene.GetResAnmLight(name);
if (light.IsValid()) {
SetBind(pId, light.GetID());
numBound++;
}
}
}
return numBound == numAllLight;
}
} // namespace g3d
} // namespace nw4r
|