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

Function xMovePointGetNext

src/SB/Core/x/xMovePoint.cpp:110–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110F32 xMovePointGetNext(const xMovePoint* m, const xMovePoint* prev, xMovePoint** next, xVec3* hdng)
111{
112 if (m->asset->numPoints < 1)
113 {
114 *next = NULL;
115 return 0.0f;
116 }
117
118 xMovePoint* previousOption = NULL;
119
120 xMovePoint** n;
121 xMovePointAsset* a;
122 S32 rnd;
123
124 rnd = xrand() % m->node_wt_sum;
125
126 n = m->nodes;
127 a = m->asset;
128
129 for (U16 idx = 0; idx < a->numPoints; idx++)
130 {
131 *next = n[idx];
132 rnd -= (*next)->asset->wt;
133 if ((*next)->on == 0)
134 {
135 *next = NULL;
136 }
137 else
138 {
139 previousOption = *next;
140 if (*next == prev)
141 {
142 *next = NULL;
143 }
144 else if (rnd < 0)
145 {
146 break;
147 }
148 }
149 }
150
151 if (*next == NULL)
152 {
153 if (previousOption != NULL)
154 {
155 *next = previousOption;
156 }
157 else
158 {
159 return 0.0f;
160 }
161 }
162
163 if (hdng)
164 {
165 return xVec3Hdng(hdng, m->pos, (*next)->pos);
166 }
167 else

Callers 2

xEntMPGetNextFunction · 0.70
zMovePointGetNextFunction · 0.50

Calls 2

xrandFunction · 0.85
xVec3HdngFunction · 0.85

Tested by

no test coverage detected