| 1156 | } |
| 1157 | |
| 1158 | float ComputeDefaultSizeFunc(int handle, float *size_ptr, vector *offset_ptr, bool f_use_all_frames) { |
| 1159 | poly_model *pm; |
| 1160 | matrix m; |
| 1161 | float normalized_time[MAX_SUBOBJECTS]; |
| 1162 | int model_index, sm_vert_index, frame_index; |
| 1163 | float cur_dist; |
| 1164 | float size = 0.0; |
| 1165 | int start_frame = 0; |
| 1166 | int end_frame = 0; |
| 1167 | |
| 1168 | vector geometric_center = Zero_vector; |
| 1169 | |
| 1170 | // Chris: Come see me when you are ready to deal with the paging problem - JL |
| 1171 | pm = GetPolymodelPointer(handle); |
| 1172 | |
| 1173 | ASSERT(start_frame <= end_frame); |
| 1174 | ASSERT(end_frame <= pm->frame_max); |
| 1175 | |
| 1176 | if (f_use_all_frames) { |
| 1177 | end_frame = pm->frame_max; |
| 1178 | } |
| 1179 | |
| 1180 | if (offset_ptr) { |
| 1181 | vector min_xyz; |
| 1182 | vector max_xyz; |
| 1183 | bool first_pnt = true; |
| 1184 | |
| 1185 | for (frame_index = start_frame; frame_index <= end_frame; frame_index++) { |
| 1186 | // Because size changes with animation, we need the worst case point -- so, check every keyframe |
| 1187 | // NOTE: This code does not currently account for all $turret and $rotate positions |
| 1188 | |
| 1189 | SetNormalizedTimeAnim(frame_index, normalized_time, pm); |
| 1190 | |
| 1191 | SetModelAnglesAndPos(pm, normalized_time); |
| 1192 | |
| 1193 | for (model_index = 0; model_index < pm->n_models; model_index++) { |
| 1194 | bsp_info *sm = &pm->submodel[model_index]; |
| 1195 | |
| 1196 | // For every vertex |
| 1197 | for (sm_vert_index = 0; sm_vert_index < sm->nverts; sm_vert_index++) { |
| 1198 | vector pnt; |
| 1199 | int mn; |
| 1200 | |
| 1201 | // Get the point and its current sub-object |
| 1202 | pnt = sm->verts[sm_vert_index]; |
| 1203 | mn = model_index; |
| 1204 | |
| 1205 | // Instance up the tree |
| 1206 | while (mn != -1) { |
| 1207 | vector tpnt; |
| 1208 | |
| 1209 | vm_AnglesToMatrix(&m, pm->submodel[mn].angs.p, pm->submodel[mn].angs.h, pm->submodel[mn].angs.b); |
| 1210 | vm_TransposeMatrix(&m); |
| 1211 | |
| 1212 | tpnt = pnt * m; |
| 1213 | |
| 1214 | pnt = tpnt + pm->submodel[mn].offset + pm->submodel[mn].mod_pos; |
| 1215 |
no test coverage detected