| 92 | } |
| 93 | |
| 94 | xModelInstance* 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; |
no test coverage detected