Makes sure a door model is ok. If not ok, brings up messagebox to tell the user Parameter: handle - the handle for the polymodel Returns: true if ok, else false
| 189 | // Parameter: handle - the handle for the polymodel |
| 190 | // Returns: true if ok, else false |
| 191 | bool VerifyDoorModel(int handle) { |
| 192 | poly_model *pm = GetPolymodelPointer(handle); |
| 193 | int s; |
| 194 | bool found_frontface = 0, found_shell = 0; |
| 195 | |
| 196 | for (s = 0; s < pm->n_models; s++) { |
| 197 | bsp_info *sm = &pm->submodel[s]; |
| 198 | |
| 199 | if (sm->flags & SOF_FRONTFACE) { |
| 200 | |
| 201 | if (sm->num_faces != 1) { |
| 202 | OutrageMessageBox("Invalid door model: Frontface has %d faces; must have 1.", sm->num_faces); |
| 203 | return 0; |
| 204 | } |
| 205 | |
| 206 | if (sm->num_children != 0) { |
| 207 | OutrageMessageBox("Invalid door model: Frontface cannot have submodels."); |
| 208 | return 0; |
| 209 | } |
| 210 | |
| 211 | found_frontface = 1; |
| 212 | } |
| 213 | |
| 214 | if (sm->flags & SOF_SHELL) { |
| 215 | |
| 216 | if (sm->num_children != 0) { |
| 217 | OutrageMessageBox("Invalid door model: Shell cannot have submodels."); |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | // check polygons in the shell. we do this by copying the poly face into a room |
| 222 | room check_room; |
| 223 | face check_face; |
| 224 | |
| 225 | check_room.verts = sm->verts; |
| 226 | check_room.faces = &check_face; |
| 227 | |
| 228 | for (int f = 0; f < sm->num_faces; f++) { |
| 229 | polyface *polyface = &sm->faces[f]; |
| 230 | |
| 231 | // copy polygon face into the room face |
| 232 | check_face.num_verts = polyface->nverts; |
| 233 | check_face.face_verts = polyface->vertnums; |
| 234 | |
| 235 | if (!ComputeFaceNormal(&check_room, 0)) { |
| 236 | OutrageMessageBox("Invalid door model: Face %d in shell has bad normal.", f); |
| 237 | return 0; |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | found_shell = 1; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | if (!found_frontface) { |
| 246 | OutrageMessageBox("Invalid door model: Missing Frontface."); |
| 247 | return 0; |
| 248 | } |
no test coverage detected