From 3791b4712b86d78b66b47b260ce76d0a31c4a6b8 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 18 Jun 2014 14:17:12 -0700 Subject: [PATCH] adding some documentation about the VerletShapes --- libraries/shared/src/VerletCapsuleShape.h | 20 ++++++++++++++++---- libraries/shared/src/VerletSphereShape.h | 7 ++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libraries/shared/src/VerletCapsuleShape.h b/libraries/shared/src/VerletCapsuleShape.h index b2a7f8be30..72cc8b7b0e 100644 --- a/libraries/shared/src/VerletCapsuleShape.h +++ b/libraries/shared/src/VerletCapsuleShape.h @@ -15,11 +15,23 @@ #include "CapsuleShape.h" -// The VerletCapsuleShape is similar to a regular CapsuleShape, except it keeps pointers -// to its endpoints which are owned by some other data structure. This allows it to -// participate in a verlet integration engine. +// The VerletCapsuleShape is similar to a regular CapsuleShape, except it keeps a pointer +// to its endpoints which are owned by some other data structure (a verlet simulation system). +// This makes it easier for the points to be moved around by constraints in the system +// as well as collisions with the shape, however it has some drawbacks: // -// Although the true_halfHeight of the VerletCapsuleShape is considered a constant +// (1) The Shape::_translation and ::_rotation data members are not used (wasted) +// +// (2) A VerletShape doesn't own the points that it uses, so you must be careful not to +// leave dangling pointers around. +// +// (3) Some const methods of VerletCapsuleShape are much more expensive than you might think. +// For example getHalfHeight() and setHalfHeight() methods must do extra computation. In +// particular setRotation() is significantly more expensive than for the CapsuleShape. +// Not too expensive to use when setting up shapes, but you woudln't want to use it deep +// down in a hot simulation loop, such as when processing collision results. Best to +// just let the verlet simulation do its thing and not try to constantly force a rotation. + class VerletCapsuleShape : public CapsuleShape { public: VerletCapsuleShape(glm::vec3* startPoint, glm::vec3* endPoint); diff --git a/libraries/shared/src/VerletSphereShape.h b/libraries/shared/src/VerletSphereShape.h index 747d02ff7c..395f5901e6 100644 --- a/libraries/shared/src/VerletSphereShape.h +++ b/libraries/shared/src/VerletSphereShape.h @@ -17,8 +17,13 @@ // The VerletSphereShape is similar to a regular SphereShape, except it keeps a pointer // to its center which is owned by some other data structure (a verlet simulation system). // This makes it easier for the points to be moved around by constraints in the system -// as well as collisions with the shape. +// as well as collisions with the shape, however it has some drawbacks: // +// (1) The Shape::_translation data member is not used (wasted) +// +// (2) A VerletShape doesn't own the points that it uses, so you must be careful not to +// leave dangling pointers around. + class VerletSphereShape : public SphereShape { public: VerletSphereShape(glm::vec3* centerPoint);