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

Method createCapsuleShape

src/engine/PhysicsCommon.cpp:372–391  ·  view source on GitHub ↗

Create and return a capsule shape * @param radius The radius of the sphere of the capsule shape * @param height The height of the capsule shape (distance betwen the two spheres centers) * @return boxShape A pointer to the created capsule shape */

Source from the content-addressed store, hash-verified

370 * @return boxShape A pointer to the created capsule shape
371 */
372CapsuleShape* PhysicsCommon::createCapsuleShape(decimal radius, decimal height) {
373
374 if (radius <= decimal(0.0)) {
375
376 RP3D_LOG("PhysicsCommon", Logger::Level::Error, Logger::Category::PhysicCommon,
377 "Error when creating a CapsuleShape: radius must be a positive value", __FILE__, __LINE__);
378 }
379
380 if (height <= decimal(0.0)) {
381
382 RP3D_LOG("PhysicsCommon", Logger::Level::Error, Logger::Category::PhysicCommon,
383 "Error when creating a CapsuleShape: height must be a positive value", __FILE__, __LINE__);
384 }
385
386 CapsuleShape* shape = new (mMemoryManager.allocate(MemoryManager::AllocationType::Pool, sizeof(CapsuleShape))) CapsuleShape(radius, height, mMemoryManager.getHeapAllocator());
387
388 mCapsuleShapes.add(shape);
389
390 return shape;
391}
392
393// Destroy a capsule collision shape
394/**

Callers 5

TestPointInsideMethod · 0.80
TestRaycastMethod · 0.80
TestWorldQueriesMethod · 0.80
DumbbellMethod · 0.80
CapsuleMethod · 0.80

Calls 2

allocateMethod · 0.45
addMethod · 0.45

Tested by 3

TestPointInsideMethod · 0.64
TestRaycastMethod · 0.64
TestWorldQueriesMethod · 0.64