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

Function xModelInstanceAlloc

src/SB/Core/x/xModel.cpp:94–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94xModelInstance* xModelInstanceAlloc(RpAtomic* data, void* object, U16 flags, U8 boneIndex,
95 U8* boneRemap)
96{
97 S32 i;
98 U32 boneCount, matCount;
99 xModelPool *curr, *found;
100 xModelInstance* dude;
101 RwMatrix* allocmats;
102
103 found = NULL;
104 boneCount = iModelNumBones(data);
105 matCount = 1 + boneCount + ((flags >> 6) & 0x1);
106
107 if (xModelInstStaticAlloc)
108 {
109 if (flags & 0x2000)
110 {
111 dude = (xModelInstance*)xMemAllocSize(sizeof(xModelInstance));
112 dude->Pool = NULL;
113 dude->Mat = NULL;
114 }
115 else
116 {
117 allocmats = (RwMatrix*)xMemAllocSizeAlign(
118 matCount * sizeof(RwMatrix) + sizeof(xModelInstance), 16);
119 dude = (xModelInstance*)(allocmats + matCount);
120 dude->Pool = NULL;
121 dude->Mat = allocmats;
122 }
123 }
124 else
125 {
126 if (flags & 0x2000)
127 {
128 flags &= (U16)~0x2000;
129 flags |= 0x8;
130 }
131
132 curr = sxModelPoolList;
133 while (curr)
134 {
135 if (curr->List && matCount <= curr->NumMatrices)
136 {
137 found = curr;
138 }
139 curr = curr->Next;
140 }
141
142 if (!found)
143 {
144 return NULL;
145 }
146
147 dude = found->List;
148 found->List = dude->Next;
149 }
150
151 dude->Next = NULL;

Callers 11

load_modelFunction · 0.70
xEntLoadModelFunction · 0.70
InitMethod · 0.50
load_modelFunction · 0.50
zEntPickupInitFunction · 0.50
zCollGeom_EntSetupFunction · 0.50
zFrag_DefaultInitFunction · 0.50
SetupMethod · 0.50
ProcessMethod · 0.50
load_modelFunction · 0.50
zEntRecurseModelInfoFunction · 0.50

Calls 4

iModelNumBonesFunction · 0.85
xMat4x3IdentityFunction · 0.85
xModelBucket_GetBucketsFunction · 0.70
xModelGetPipeFlagsFunction · 0.70

Tested by

no test coverage detected