Skip to content

Commit

Permalink
Removed the need for specifying -Wno-comment when compiling with GCC (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouwe authored Nov 18, 2023
1 parent affe4fc commit 8ad7c87
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 78 deletions.
3 changes: 1 addition & 2 deletions Build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,9 @@ elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQU
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# Somehow -Wcomment doesn't want to be turned off from code and we need this because Doxygen MathJax uses it
# Also disable -Wstringop-overflow or it will generate false positives that can't be disabled from code when link-time optimizations are enabled
# Also turn off automatic fused multiply add contractions, there doesn't seem to be a way to do this selectively through the macro JPH_PRECISE_MATH_OFF
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment -Wno-stringop-overflow -ffp-contract=off")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow -ffp-contract=off")
else()
# Do not use -ffast-math since it cannot be turned off in a single compilation unit under clang, see Core.h
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-model=precise")
Expand Down
38 changes: 20 additions & 18 deletions Jolt/Physics/Collision/Shape/HeightFieldShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,24 +318,26 @@ void HeightFieldShape::CalculateActiveEdges(uint inX, uint inY, uint inSizeX, ui

void HeightFieldShape::CalculateActiveEdges(const HeightFieldShapeSettings &inSettings)
{
// Store active edges. The triangles are organized like this:
// x --->
//
// y + +
// | \ T1B | \ T2B
// | e0 e2 | \
// | | T1A \ | T2A \
// V +--e1---+-------+
// | \ T3B | \ T4B
// | \ | \
// | T3A \ | T4A \
// +-------+-------+
// We store active edges e0 .. e2 as bits 0 .. 2.
// We store triangles horizontally then vertically (order T1A, T2A, T3A and T4A).
// The top edge and right edge of the heightfield are always active so we do not need to store them,
// therefore we only need to store (mSampleCount - 1)^2 * 3-bit
// The triangles T1B, T2B, T3B and T4B do not need to be stored, their active edges can be constructed from adjacent triangles.
// Add 1 byte padding so we can always read 1 uint16 to get the bits that cross an 8 bit boundary
/*
Store active edges. The triangles are organized like this:
x --->
y + +
| \ T1B | \ T2B
| e0 e2 | \
| | T1A \ | T2A \
V +--e1---+-------+
| \ T3B | \ T4B
| \ | \
| T3A \ | T4A \
+-------+-------+
We store active edges e0 .. e2 as bits 0 .. 2.
We store triangles horizontally then vertically (order T1A, T2A, T3A and T4A).
The top edge and right edge of the heightfield are always active so we do not need to store them,
therefore we only need to store (mSampleCount - 1)^2 * 3-bit
The triangles T1B, T2B, T3B and T4B do not need to be stored, their active edges can be constructed from adjacent triangles.
Add 1 byte padding so we can always read 1 uint16 to get the bits that cross an 8 bit boundary
*/
mActiveEdges.resize((Square(mSampleCount - 1) * 3 + 7) / 8 + 1);

// Make all edges active (if mSampleCount is bigger than inSettings.mSampleCount we need to fill up the padding,
Expand Down
64 changes: 33 additions & 31 deletions Jolt/Physics/Constraints/ConstraintPart/DualAxisConstraintPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,39 @@

JPH_NAMESPACE_BEGIN

/// Constrains movement on 2 axis
///
/// @see "Constraints Derivation for Rigid Body Simulation in 3D" - Daniel Chappuis, section 2.3.1
///
/// Constraint equation (eq 51):
///
/// \f[C = \begin{bmatrix} (p_2 - p_1) \cdot n_1 \\ (p_2 - p_1) \cdot n_2\end{bmatrix}\f]
///
/// Jacobian (transposed) (eq 55):
///
/// \f[J^T = \begin{bmatrix}
/// -n_1 & -n_2 \\
/// -(r_1 + u) \times n_1 & -(r_1 + u) \times n_2 \\
/// n_1 & n_2 \\
/// r_2 \times n_1 & r_2 \times n_2
/// \end{bmatrix}\f]
///
/// Used terms (here and below, everything in world space):\n
/// n1, n2 = constraint axis (normalized).\n
/// p1, p2 = constraint points.\n
/// r1 = p1 - x1.\n
/// r2 = p2 - x2.\n
/// u = x2 + r2 - x1 - r1 = p2 - p1.\n
/// x1, x2 = center of mass for the bodies.\n
/// v = [v1, w1, v2, w2].\n
/// v1, v2 = linear velocity of body 1 and 2.\n
/// w1, w2 = angular velocity of body 1 and 2.\n
/// M = mass matrix, a diagonal matrix of the mass and inertia with diagonal [m1, I1, m2, I2].\n
/// \f$K^{-1} = \left( J M^{-1} J^T \right)^{-1}\f$ = effective mass.\n
/// b = velocity bias.\n
/// \f$\beta\f$ = baumgarte constant.
/**
Constrains movement on 2 axis
@see "Constraints Derivation for Rigid Body Simulation in 3D" - Daniel Chappuis, section 2.3.1
Constraint equation (eq 51):
\f[C = \begin{bmatrix} (p_2 - p_1) \cdot n_1 \\ (p_2 - p_1) \cdot n_2\end{bmatrix}\f]
Jacobian (transposed) (eq 55):
\f[J^T = \begin{bmatrix}
-n_1 & -n_2 \\
-(r_1 + u) \times n_1 & -(r_1 + u) \times n_2 \\
n_1 & n_2 \\
r_2 \times n_1 & r_2 \times n_2
\end{bmatrix}\f]
Used terms (here and below, everything in world space):\n
n1, n2 = constraint axis (normalized).\n
p1, p2 = constraint points.\n
r1 = p1 - x1.\n
r2 = p2 - x2.\n
u = x2 + r2 - x1 - r1 = p2 - p1.\n
x1, x2 = center of mass for the bodies.\n
v = [v1, w1, v2, w2].\n
v1, v2 = linear velocity of body 1 and 2.\n
w1, w2 = angular velocity of body 1 and 2.\n
M = mass matrix, a diagonal matrix of the mass and inertia with diagonal [m1, I1, m2, I2].\n
\f$K^{-1} = \left( J M^{-1} J^T \right)^{-1}\f$ = effective mass.\n
b = velocity bias.\n
\f$\beta\f$ = baumgarte constant.
**/
class DualAxisConstraintPart
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,35 @@

JPH_NAMESPACE_BEGIN

/// Constrains rotation around 2 axis so that it only allows rotation around 1 axis
///
/// Based on: "Constraints Derivation for Rigid Body Simulation in 3D" - Daniel Chappuis, section 2.4.1
///
/// Constraint equation (eq 87):
///
/// \f[C = \begin{bmatrix}a_1 \cdot b_2 \\ a_1 \cdot c_2\end{bmatrix}\f]
///
/// Jacobian (eq 90):
///
/// \f[J = \begin{bmatrix}
/// 0 & -b_2 \times a_1 & 0 & b_2 \times a_1 \\
/// 0 & -c_2 \times a_1 & 0 & c2 \times a_1
/// \end{bmatrix}\f]
///
/// Used terms (here and below, everything in world space):\n
/// a1 = hinge axis on body 1.\n
/// b2, c2 = axis perpendicular to hinge axis on body 2.\n
/// x1, x2 = center of mass for the bodies.\n
/// v = [v1, w1, v2, w2].\n
/// v1, v2 = linear velocity of body 1 and 2.\n
/// w1, w2 = angular velocity of body 1 and 2.\n
/// M = mass matrix, a diagonal matrix of the mass and inertia with diagonal [m1, I1, m2, I2].\n
/// \f$K^{-1} = \left( J M^{-1} J^T \right)^{-1}\f$ = effective mass.\n
/// b = velocity bias.\n
/// \f$\beta\f$ = baumgarte constant.\n
/// E = identity matrix.
/**
Constrains rotation around 2 axis so that it only allows rotation around 1 axis
Based on: "Constraints Derivation for Rigid Body Simulation in 3D" - Daniel Chappuis, section 2.4.1
Constraint equation (eq 87):
\f[C = \begin{bmatrix}a_1 \cdot b_2 \\ a_1 \cdot c_2\end{bmatrix}\f]
Jacobian (eq 90):
\f[J = \begin{bmatrix}
0 & -b_2 \times a_1 & 0 & b_2 \times a_1 \\
0 & -c_2 \times a_1 & 0 & c2 \times a_1
\end{bmatrix}\f]
Used terms (here and below, everything in world space):\n
a1 = hinge axis on body 1.\n
b2, c2 = axis perpendicular to hinge axis on body 2.\n
x1, x2 = center of mass for the bodies.\n
v = [v1, w1, v2, w2].\n
v1, v2 = linear velocity of body 1 and 2.\n
w1, w2 = angular velocity of body 1 and 2.\n
M = mass matrix, a diagonal matrix of the mass and inertia with diagonal [m1, I1, m2, I2].\n
\f$K^{-1} = \left( J M^{-1} J^T \right)^{-1}\f$ = effective mass.\n
b = velocity bias.\n
\f$\beta\f$ = baumgarte constant.\n
E = identity matrix.
**/
class HingeRotationConstraintPart
{
public:
Expand Down

0 comments on commit 8ad7c87

Please sign in to comment.