Add documentation

This commit is contained in:
Daniel Chappuis 2012-08-06 22:34:42 +02:00
parent 29e5f2b7b4
commit fcac6457a7
3 changed files with 11 additions and 4 deletions

View File

@ -115,7 +115,6 @@ inline bool PairManager::isDifferentPair(const BroadPhasePair& pair1, bodyindex
}
// Return the next power of two of a 32bits integer using a SWAR algorithm
// TODO : Add documentation
inline luint PairManager::computeNextPowerOfTwo(luint number) const {
number |= (number >> 1);
number |= (number >> 2);
@ -149,7 +148,8 @@ inline void PairManager::sortIDs(bodyindex &id1, bodyindex &id2) const {
// This method returns an hash value for a 32 bits key
// using Thomas Wang's hash technique.
// TODO : Add documentation here
// This hash function can be found at :
// http://www.concentric.net/~ttwang/tech/inthash.htm
inline int PairManager::computeHash32Bits(int key) const {
key += ~(key << 15);
key ^= (key >> 10);

View File

@ -112,8 +112,12 @@ class SweepAndPruneAlgorithm : public BroadPhaseAlgorithm {
virtual void updateObject(Body* body, const AABB& aabb); // Notify the broad-phase that the AABB of an object has changed
};
// TODO : ADD Documentation for this method
// Encode a floating value into a integer value
// Encode a floating value into a integer value in order to
// work with integer comparison in the Sweep-And-Prune algorithm
// because it is faster. The main issue when encoding floating
// number into integer is to keep to sorting order. This is a
// problem for negative float number. This article describes
// how to solve this issue : http://www.stereopsis.com/radix.html
inline uint encodeFloatIntoInteger(float number) {
uint intNumber = (uint&) number;

View File

@ -56,6 +56,9 @@ RigidBody* PhysicsWorld::createRigidBody(const Transform& transform, decimal mas
currentBodyID++;
}
// Largest index cannot be used (it is used for invalid index)
assert(bodyID < std::numeric_limits<reactphysics3d::bodyindex>::max());
// Create the rigid body
RigidBody* rigidBody = new (memoryPoolRigidBodies.allocateObject()) RigidBody(transform, mass, inertiaTensorLocal, collisionShape, bodyID);