MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / createHeightField

Method createHeightField

src/engine/PhysicsCommon.cpp:480–504  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

478 * @return A pointer to the created height-field
479 */
480HeightField* 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/**

Callers 3

TestHeightFieldMethod · 0.80
TestRaycastMethod · 0.80
HeightFieldMethod · 0.80

Calls 5

~HeightFieldMethod · 0.80
allocateMethod · 0.45
initMethod · 0.45
releaseMethod · 0.45
addMethod · 0.45

Tested by 2

TestHeightFieldMethod · 0.64
TestRaycastMethod · 0.64