| 309 | } |
| 310 | |
| 311 | void Cloth::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) |
| 312 | { |
| 313 | Actor::Deserialize(stream, modifier); |
| 314 | |
| 315 | PROFILE_MEM(PhysicsCloth); |
| 316 | DESERIALIZE_MEMBER(Mesh, _mesh); |
| 317 | _mesh.Actor = nullptr; // Don't store this reference |
| 318 | DESERIALIZE_MEMBER(Force, _forceSettings); |
| 319 | DESERIALIZE_MEMBER(Collision, _collisionSettings); |
| 320 | DESERIALIZE_MEMBER(Simulation, _simulationSettings); |
| 321 | DESERIALIZE_MEMBER(Fabric, _fabricSettings); |
| 322 | DESERIALIZE_MEMBER(Paint, _paint); |
| 323 | |
| 324 | #if USE_CLOTH_SANITY_CHECKS |
| 325 | { |
| 326 | // Sanity check |
| 327 | const float* data = _paint.Get(); |
| 328 | bool allValid = true; |
| 329 | for (int32 i = 0; i < _paint.Count(); i++) |
| 330 | allValid &= !isnan(data[i]) && !isinf(data[i]); |
| 331 | ASSERT(allValid); |
| 332 | } |
| 333 | #endif |
| 334 | |
| 335 | // Refresh cloth when settings were changed |
| 336 | #if WITH_CLOTH |
| 337 | if (_cloth) |
| 338 | Rebuild(); |
| 339 | #endif |
| 340 | } |
| 341 | |
| 342 | #if USE_EDITOR |
| 343 | |