Skip to content

Commit 64fa594

Browse files
Changes for issue #217...
- Adds documentation comments regarding use of visitor pattern. - Updates documentation comments to more thoroughly explain what types can be used for the Real type alias.
1 parent 5e84d32 commit 64fa594

File tree

6 files changed

+64
-30
lines changed

6 files changed

+64
-30
lines changed

PlayRho/Collision/Shapes/Shape.hpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ struct ShapeDef;
4343
///
4444
/// @details This is a polymorphic abstract base class for shapes.
4545
/// A shape is used for collision detection. You can create a shape however you like.
46-
/// Shapes used for simulation in World are created automatically when a Fixture
47-
/// is created. Shapes may encapsulate zero or more child shapes.
46+
/// Shapes used for simulation in <code>World</code> are created automatically when a
47+
/// <code>Fixture</code> is created. Shapes may encapsulate zero or more child shapes.
4848
///
4949
/// @note This data structure is 32-bytes large (on at least one 64-bit platform).
5050
///
5151
/// @ingroup PartsGroup
5252
///
53+
/// @sa Fixture
54+
///
5355
class Shape
5456
{
5557
public:
@@ -73,6 +75,10 @@ class Shape
7375
virtual MassData GetMassData() const noexcept = 0;
7476

7577
/// @brief Accepts a visitor.
78+
/// @details This is the Accept method definition of a "visitor design pattern" for
79+
/// for doing shape subclass specific types of processing for a constant shape.
80+
/// @sa ShapeVisitor
81+
/// @sa https://en.wikipedia.org/wiki/Visitor_pattern
7682
virtual void Accept(ShapeVisitor& visitor) const = 0;
7783

7884
/// @brief Gets the vertex radius.

PlayRho/Common/Fixed.hpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@
3333

3434
namespace playrho
3535
{
36-
/// @brief A fixed-point template class.
36+
/// @brief Template class for fixed-point numbers.
3737
///
3838
/// @details This is a fixed point type template for a given base type using a given number
39-
/// of fraction bits.
39+
/// of fraction bits that satisfies the "LiteralType" concept.
4040
///
4141
/// @note For a 32-bit sized fixed point type with a 14-bit fraction part
4242
/// 0.000061035156250 is the smallest double precision value that can be represented.
4343
///
44+
/// @sa https://en.wikipedia.org/wiki/Fixed-point_arithmetic
45+
/// @sa http://en.cppreference.com/w/cpp/concept/LiteralType
46+
///
4447
template <typename BASE_TYPE, unsigned int FRACTION_BITS>
4548
class Fixed
4649
{

PlayRho/Common/Real.hpp

+21-13
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,31 @@ namespace playrho {
3838
/// real-numbers. Ideally the implementation of this type doesn't suffer from things like:
3939
/// catastrophic cancellation, catastrophic division, overflows, nor underflows.
4040
///
41-
/// @note This can be implemented using float, double, long double, Fixed64, or Fixed32
42-
/// (though the use of Fixed32 is discouraged).
41+
/// @note This can be implemented using any of the fundamental floating point types (
42+
/// <code>float</code>, <code>double</code>, or <code>long double</code>).
43+
/// @note This can also be implemented using a "LiteralType" that has the necessary support:
44+
/// all common mathematical functions, support for infinity and NaN, and a specialization
45+
/// of the <code>std::numeric_limits</code> class template for it.
46+
/// @note At present, the <code>Fixed32</code> and <code>Fixed64</code> aliases of the
47+
/// <code>Fixed</code> template type are provided as examples of qualifying literal types
48+
/// though the usability of <code>Fixed32</code> is limited and its use is discouraged.
4349
///
4450
/// @note Regarding division:
51+
/// - While dividing 1 by a real, caching the result, and then doing multiplications with the
52+
/// result may well be faster (than repeatedly dividing), dividing 1 by the real can also
53+
/// result in an underflow situation that's then compounded every time it's multiplied with
54+
/// other values.
55+
/// - Meanwhile, dividing every time by a real isolates any underflows to the particular
56+
/// division where underflow occurs.
4557
///
46-
/// While dividing 1 by a Real, caching the result, and then doing multiplications with the
47-
/// result may well be faster (than repeatedly dividing), dividing 1 by Real can also result
48-
/// in an underflow situation that's then compounded every time it's multiplied with other
49-
/// values.
50-
///
51-
/// Meanwhile, dividing every value by Real isolates any underflows to the particular
52-
/// division where underflow occurs.
53-
///
54-
/// @warning Using Fixed32 is not advised as it's numerical limitations are more likely to
55-
/// result in problems like overflows or underflows.
58+
/// @warning Using <code>Fixed32</code> is not advised as it's numerical limitations are more
59+
/// likely to result in problems like overflows or underflows.
5660
/// @warning The note regarding division applies even more so when using a fixed-point type
57-
/// (for Real).
61+
/// (for <code>Real</code>).
62+
///
63+
/// @sa http://en.cppreference.com/w/cpp/language/types
64+
/// @sa http://en.cppreference.com/w/cpp/types/is_floating_point
65+
/// @sa http://en.cppreference.com/w/cpp/concept/LiteralType
5866
///
5967
using Real = float;
6068

PlayRho/Common/Real.hpp.in

+21-13
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,31 @@ namespace playrho {
3838
/// real-numbers. Ideally the implementation of this type doesn't suffer from things like:
3939
/// catastrophic cancellation, catastrophic division, overflows, nor underflows.
4040
///
41-
/// @note This can be implemented using float, double, long double, Fixed64, or Fixed32
42-
/// (though the use of Fixed32 is discouraged).
41+
/// @note This can be implemented using any of the fundamental floating point types (
42+
/// <code>float</code>, <code>double</code>, or <code>long double</code>).
43+
/// @note This can also be implemented using a "LiteralType" that has the necessary support:
44+
/// all common mathematical functions, support for infinity and NaN, and a specialization
45+
/// of the <code>std::numeric_limits</code> class template for it.
46+
/// @note At present, the <code>Fixed32</code> and <code>Fixed64</code> aliases of the
47+
/// <code>Fixed</code> template type are provided as examples of qualifying literal types
48+
/// though the usability of <code>Fixed32</code> is limited and its use is discouraged.
4349
///
4450
/// @note Regarding division:
51+
/// - While dividing 1 by a real, caching the result, and then doing multiplications with the
52+
/// result may well be faster (than repeatedly dividing), dividing 1 by the real can also
53+
/// result in an underflow situation that's then compounded every time it's multiplied with
54+
/// other values.
55+
/// - Meanwhile, dividing every time by a real isolates any underflows to the particular
56+
/// division where underflow occurs.
4557
///
46-
/// While dividing 1 by a Real, caching the result, and then doing multiplications with the
47-
/// result may well be faster (than repeatedly dividing), dividing 1 by Real can also result
48-
/// in an underflow situation that's then compounded every time it's multiplied with other
49-
/// values.
50-
///
51-
/// Meanwhile, dividing every value by Real isolates any underflows to the particular
52-
/// division where underflow occurs.
53-
///
54-
/// @warning Using Fixed32 is not advised as it's numerical limitations are more likely to
55-
/// result in problems like overflows or underflows.
58+
/// @warning Using <code>Fixed32</code> is not advised as it's numerical limitations are more
59+
/// likely to result in problems like overflows or underflows.
5660
/// @warning The note regarding division applies even more so when using a fixed-point type
57-
/// (for Real).
61+
/// (for <code>Real</code>).
62+
///
63+
/// @sa http://en.cppreference.com/w/cpp/language/types
64+
/// @sa http://en.cppreference.com/w/cpp/types/is_floating_point
65+
/// @sa http://en.cppreference.com/w/cpp/concept/LiteralType
5866
///
5967
using Real = @PLAYRHO_REAL_TYPE@;
6068

PlayRho/Common/RealConstants.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#ifndef PLAYRHO_COMMON_REALCONSTANTS_HPP
3030
#define PLAYRHO_COMMON_REALCONSTANTS_HPP
3131

32+
#include <PlayRho/Defines.hpp>
3233
#include <PlayRho/Common/Real.hpp>
3334

3435
namespace playrho {

PlayRho/Dynamics/Joints/Joint.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,17 @@ class Joint
105105
virtual AngularMomentum GetAngularReaction() const = 0;
106106

107107
/// @brief Accepts a visitor.
108+
/// @details This is the Accept method definition of a "visitor design pattern" for
109+
/// for doing joint subclass specific types of processing for a constant joint.
110+
/// @sa JointVisitor
111+
/// @sa https://en.wikipedia.org/wiki/Visitor_pattern
108112
virtual void Accept(JointVisitor& visitor) const = 0;
109113

110114
/// @brief Accepts a visitor.
115+
/// @details This is the Accept method definition of a "visitor design pattern" for
116+
/// for doing joint subclass specific types of processing.
117+
/// @sa JointVisitor
118+
/// @sa https://en.wikipedia.org/wiki/Visitor_pattern
111119
virtual void Accept(JointVisitor& visitor) = 0;
112120

113121
/// Get the user data pointer.

0 commit comments

Comments
 (0)