| 59 | } |
| 60 | |
| 61 | void ShatterObject(SHATTER_ITEM* item, StaticMesh* mesh, int num, short roomNumber, int noZXVel) |
| 62 | { |
| 63 | int meshIndex = 0; |
| 64 | short yRot = 0; |
| 65 | Vector3 scale; |
| 66 | Vector3 pos; |
| 67 | bool isStatic; |
| 68 | |
| 69 | if (mesh) |
| 70 | { |
| 71 | if (!(mesh->Flags & StaticMeshFlags::SM_VISIBLE)) |
| 72 | return; |
| 73 | |
| 74 | isStatic = true; |
| 75 | meshIndex = Statics[mesh->Slot].meshNumber; |
| 76 | yRot = mesh->Pose.Orientation.y; |
| 77 | pos = Vector3(mesh->Pose.Position.x, mesh->Pose.Position.y, mesh->Pose.Position.z); |
| 78 | scale = mesh->Pose.Scale; |
| 79 | |
| 80 | if (mesh->HitPoints <= 0) |
| 81 | mesh->Flags &= ~StaticMeshFlags::SM_VISIBLE; |
| 82 | |
| 83 | SmashedMeshRoom[SmashedMeshCount] = roomNumber; |
| 84 | SmashedMesh[SmashedMeshCount] = mesh; |
| 85 | SmashedMeshCount++; |
| 86 | } |
| 87 | else |
| 88 | { |
| 89 | isStatic = false; |
| 90 | meshIndex = item->meshIndex; |
| 91 | yRot = item->yRot; |
| 92 | pos = item->sphere.Center; |
| 93 | scale = Vector3::One; |
| 94 | } |
| 95 | |
| 96 | auto fragmentsMesh = &g_Level.Meshes[meshIndex]; |
| 97 | |
| 98 | for (auto& renderBucket : fragmentsMesh->buckets) |
| 99 | { |
| 100 | for (int i = 0; i < renderBucket.polygons.size(); i++) |
| 101 | { |
| 102 | POLYGON* poly = &renderBucket.polygons[i]; |
| 103 | int indices[6]; |
| 104 | |
| 105 | if (poly->shape == SHAPE_RECTANGLE) |
| 106 | { |
| 107 | indices[0] = 0; |
| 108 | indices[1] = 1; |
| 109 | indices[2] = 3; |
| 110 | indices[3] = 2; |
| 111 | indices[4] = 3; |
| 112 | indices[5] = 1; |
| 113 | } |
| 114 | else |
| 115 | { |
| 116 | indices[0] = 0; |
| 117 | indices[1] = 1; |
| 118 | indices[2] = 2; |
no test coverage detected