| 450 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 451 | |
| 452 | PxHeightField* Cooking::createHeightField(const PxHeightFieldDesc& desc, PxPhysicsInsertionCallback& insertionCallback) const |
| 453 | { |
| 454 | PX_FPU_GUARD; |
| 455 | |
| 456 | if(!desc.isValid()) |
| 457 | { |
| 458 | #if PX_CHECKED |
| 459 | Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, "Cooking::createHeightField: user-provided heightfield descriptor is invalid!"); |
| 460 | #endif |
| 461 | return NULL; |
| 462 | } |
| 463 | |
| 464 | Gu::HeightField* hf; |
| 465 | PX_NEW_SERIALIZED(hf, Gu::HeightField)(NULL); |
| 466 | |
| 467 | if(!hf->loadFromDesc(desc)) |
| 468 | { |
| 469 | PX_DELETE(hf); |
| 470 | return NULL; |
| 471 | } |
| 472 | |
| 473 | // create heightfield and set the HF data |
| 474 | Gu::HeightField* heightField = static_cast<Gu::HeightField*>(insertionCallback.buildObjectFromData(PxConcreteType::eHEIGHTFIELD, &hf->mData)); |
| 475 | if(!heightField) |
| 476 | { |
| 477 | PX_DELETE(hf); |
| 478 | return NULL; |
| 479 | } |
| 480 | |
| 481 | // copy the Gu::HeightField variables |
| 482 | heightField->mSampleStride = hf->mSampleStride; |
| 483 | heightField->mNbSamples = hf->mNbSamples; |
| 484 | heightField->mMinHeight = hf->mMinHeight; |
| 485 | heightField->mMaxHeight = hf->mMaxHeight; |
| 486 | heightField->mModifyCount = hf->mModifyCount; |
| 487 | |
| 488 | PX_DELETE(hf); |
| 489 | return heightField; |
| 490 | } |
| 491 | |
| 492 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 493 |
nothing calls this directly
no test coverage detected