| 213 | |
| 214 | |
| 215 | void CustomMesh::writeToGroupDef(GroupDefinition* groupdef) const { |
| 216 | // include the old style parameters |
| 217 | MeshTransform xform; |
| 218 | if ((size.x != 1.0f) || (size.y != 1.0f) || (size.z != 1.0f)) { |
| 219 | xform.addScale(size); |
| 220 | } |
| 221 | if (rotation != 0.0f) { |
| 222 | const fvec3 zAxis(0.0f, 0.0f, 1.0f); |
| 223 | xform.addSpin((float)(rotation * (180.0 / M_PI)), zAxis); |
| 224 | } |
| 225 | if ((pos.x != 0.0f) || (pos.y != 0.0f) || (pos.z != 0.0f)) { |
| 226 | xform.addShift(pos); |
| 227 | } |
| 228 | xform.append(transform); |
| 229 | |
| 230 | // hack to invalidate decorative meshes on older clients |
| 231 | bool forcePassable = false; |
| 232 | if (drawInfo) { |
| 233 | fvec3 vert; |
| 234 | if (decorative) { |
| 235 | vert.x = vert.y = vert.z = (Obstacle::maxExtent * 2.0f); |
| 236 | if ((faces.size() > 0) && !(driveThrough && shootThrough)) { |
| 237 | debugf(0, "WARNING: mesh is supposed to be decorative, setting to passable\n"); |
| 238 | forcePassable = true; |
| 239 | } |
| 240 | } |
| 241 | else { |
| 242 | vert.x = vert.y = vert.z = 0.0f; |
| 243 | } |
| 244 | ((std::vector<fvec3>*)&vertices)->push_back(vert); |
| 245 | } |
| 246 | |
| 247 | MeshObstacle* mesh = |
| 248 | new MeshObstacle(xform, checkTypes, checkPoints, |
| 249 | vertices, normals, texcoords, faces.size(), |
| 250 | noclusters, smoothBounce, |
| 251 | driveThrough || forcePassable, |
| 252 | shootThrough || forcePassable, |
| 253 | ricochet); |
| 254 | |
| 255 | mesh->setName(name); |
| 256 | |
| 257 | // add the faces |
| 258 | std::vector<CustomMeshFace*>::const_iterator faceIt; |
| 259 | for (faceIt = faces.begin(); faceIt != faces.end(); faceIt++) { |
| 260 | const CustomMeshFace* customFace = *faceIt; |
| 261 | customFace->write(mesh); |
| 262 | } |
| 263 | |
| 264 | // add the weapons |
| 265 | std::vector<std::vector<std::string>*>::const_iterator weaponIt; |
| 266 | for (weaponIt = weapons.begin(); weaponIt != weapons.end(); weaponIt++) { |
| 267 | mesh->addWeapon(**weaponIt); |
| 268 | } |
| 269 | |
| 270 | mesh->finalize(); |
| 271 | |
| 272 | if (!mesh->isValid()) { |
nothing calls this directly
no test coverage detected