Create and return a height-field * @param nbGridColumns Number of columns in the grid of the height field (along the local x axis) * @param nbGridRows Number of rows in the grid of the height field (along the local z axis) * @param heightFieldData Pointer to the first height value data (note that values are copied into the heigh-field) * @param dataType Data type for the height values (int, flo
| 478 | * @return A pointer to the created height-field |
| 479 | */ |
| 480 | HeightField* PhysicsCommon::createHeightField(int nbGridColumns, int nbGridRows, |
| 481 | const void* heightFieldData, |
| 482 | HeightField::HeightDataType dataType, |
| 483 | std::vector<Message>& messages, |
| 484 | decimal integerHeightScale) { |
| 485 | |
| 486 | // Create the height-field |
| 487 | HeightField* heightField = new (mMemoryManager.allocate(MemoryManager::AllocationType::Pool, sizeof(TriangleMesh))) HeightField(mMemoryManager.getHeapAllocator(), mTriangleShapeHalfEdgeStructure); |
| 488 | |
| 489 | // Initialize the height-field |
| 490 | bool isValid = heightField->init(nbGridColumns, nbGridRows, heightFieldData, dataType, messages, |
| 491 | integerHeightScale); |
| 492 | |
| 493 | if (!isValid) { |
| 494 | |
| 495 | heightField->~HeightField(); |
| 496 | mMemoryManager.release(MemoryManager::AllocationType::Pool, heightField, sizeof(HeightField)); |
| 497 | |
| 498 | return nullptr; |
| 499 | } |
| 500 | |
| 501 | mHeightFields.add(heightField); |
| 502 | |
| 503 | return heightField; |
| 504 | } |
| 505 | |
| 506 | // Create and return a height-field collision shape |
| 507 | /** |