Skip to content

Commit 8a28334

Browse files
committed
Merge branch 'master' of https://github.com/sofa-framework/sofa
2 parents 93fb788 + b424801 commit 8a28334

File tree

13 files changed

+769
-31
lines changed

13 files changed

+769
-31
lines changed

.github/workflows/nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
os: [ubuntu, macos]
1313
steps:
1414
- uses: actions/checkout@v4
15-
- uses: cachix/install-nix-action@v27
15+
- uses: cachix/install-nix-action@v31
1616
# TODO: the "sofa" account on cachix does not exist yet
1717
#- uses: cachix/cachix-action@v15
1818
#with:

CHANGELOG.md

Lines changed: 233 additions & 0 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
1212
endif()
1313

1414
# Manually define VERSION
15-
set(Sofa_VERSION_MAJOR 25)
16-
set(Sofa_VERSION_MINOR 12)
15+
set(Sofa_VERSION_MAJOR 26)
16+
set(Sofa_VERSION_MINOR 06)
1717
set(Sofa_VERSION_PATCH 99)
1818
set(Sofa_VERSION ${Sofa_VERSION_MAJOR}.${Sofa_VERSION_MINOR}.${Sofa_VERSION_PATCH})
1919

Sofa/Component/Collision/Detection/Algorithm/src/sofa/component/collision/detection/algorithm/BaseSubCollisionPipeline.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ void BaseSubCollisionPipeline::init()
5252
doInit();
5353
}
5454

55+
void BaseSubCollisionPipeline::bwdInit()
56+
{
57+
doBwdInit();
58+
}
59+
5560
/**
5661
* @brief Queries all registered contact response types from the Contact factory.
5762
*

Sofa/Component/Collision/Detection/Algorithm/src/sofa/component/collision/detection/algorithm/BaseSubCollisionPipeline.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class SOFA_COMPONENT_COLLISION_DETECTION_ALGORITHM_API BaseSubCollisionPipeline
8585

8686
/// @brief Initializes the component. Marked final to enforce Template Method pattern.
8787
void init() override final;
88+
89+
/// @brief Initialization of the component during the bottom-up traversal. Marked final to enforce Template Method pattern.
90+
void bwdInit() override final;
8891

8992
/// @brief Renders debug visualization. Marked final to enforce Template Method pattern.
9093
void draw(const core::visual::VisualParams* vparams) override final;

Sofa/Component/Collision/Detection/Algorithm/src/sofa/component/collision/detection/algorithm/CompositeCollisionPipeline.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ void CompositeCollisionPipeline::init()
122122
}
123123

124124
}
125+
void CompositeCollisionPipeline::bwdInit()
126+
{
127+
for(const auto& subPipeline : l_subCollisionPipelines)
128+
{
129+
subPipeline->bwdInit();
130+
}
131+
}
125132

126133
void CompositeCollisionPipeline::reset()
127134
{

Sofa/Component/Collision/Detection/Algorithm/src/sofa/component/collision/detection/algorithm/CompositeCollisionPipeline.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class SOFA_COMPONENT_COLLISION_DETECTION_ALGORITHM_API CompositeCollisionPipelin
7777
/// @brief Delegates response creation to all sub-pipelines.
7878
void doCollisionResponse() override;
7979

80+
void bwdInit() override;
8081
void reset() override;
8182

8283
/// @brief Entry point for collision reset, called by the simulation loop.

Sofa/framework/Type/src/sofa/type/Vec.h

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <cmath>
3333
#include <array>
3434
#include <cassert>
35+
#include <numeric>
3536

3637
#define EQUALITY_THRESHOLD 1e-6
3738

@@ -257,8 +258,7 @@ class Vec
257258
// assign one value to all elements
258259
constexpr void assign(const ValueType& value) noexcept
259260
{
260-
for (size_type i = 0; i < N; i++)
261-
elems[i] = value;
261+
std::fill_n(this->elems.data(), N, value);
262262
}
263263

264264
/// Sets every element to 0.
@@ -472,6 +472,10 @@ class Vec
472472
/// Squared norm.
473473
constexpr ValueType norm2() const noexcept
474474
{
475+
// The STL function is slower when not compiling in full optimization.
476+
// Therefore, the debugging would be slower.
477+
// return std::inner_product(elems.begin(), elems.end(), elems.begin(), ValueType{});
478+
475479
ValueType r = this->elems[0]*this->elems[0];
476480
for (Size i=1; i<N; i++)
477481
r += this->elems[i]*this->elems[i];
@@ -583,7 +587,10 @@ class Vec
583587
/// sum of all elements of the vector
584588
constexpr ValueType sum() const noexcept
585589
{
586-
ValueType sum = ValueType(0.0);
590+
// The STL function is slower when not compiling in full optimization.
591+
// Therefore, the debugging would be slower.
592+
// return std::accumulate(elems.begin(), elems.end(), ValueType{});
593+
ValueType sum = static_cast<ValueType>(0.0);
587594
for (Size i=0; i<N; i++)
588595
sum += this->elems[i];
589596
return sum;
@@ -597,8 +604,8 @@ class Vec
597604
{
598605
if constexpr (std::is_floating_point_v<ValueType>)
599606
{
600-
return std::equal(this->elems.begin(), this->elems.end(), b.elems.begin(),
601-
[](auto x, auto y) { return std::abs(x - y) < EQUALITY_THRESHOLD; });
607+
constexpr auto equalTest = [](auto x, auto y) { return std::abs(x - y) < EQUALITY_THRESHOLD; };
608+
return std::equal(this->elems.begin(), this->elems.end(), b.elems.begin(), equalTest );
602609
}
603610
else
604611
{
@@ -680,19 +687,19 @@ class Vec
680687
return elems.end();
681688
}
682689

683-
constexpr reference front()
690+
constexpr reference front() noexcept
684691
{
685692
return elems[0];
686693
}
687-
constexpr const_reference front() const
694+
constexpr const_reference front() const noexcept
688695
{
689696
return elems[0];
690697
}
691-
constexpr reference back()
698+
constexpr reference back() noexcept
692699
{
693700
return elems[N - 1];
694701
}
695-
constexpr const_reference back() const
702+
constexpr const_reference back() const noexcept
696703
{
697704
return elems[N - 1];
698705
}
@@ -717,7 +724,7 @@ class VecNoInit : public Vec<N,real>
717724
{}
718725

719726
constexpr VecNoInit(Vec<N,real>&& v) noexcept
720-
: Vec<N,real>(v)
727+
: Vec<N,real>(std::move(v))
721728
{}
722729

723730
using Vec<N,real>::Vec;

Sofa/framework/Type/src/sofa/type/fixed_array_algorithms.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,25 @@
2121
******************************************************************************/
2222
#pragma once
2323

24-
namespace sofa::type::pairwise
25-
{
24+
#include <algorithm>
2625

27-
/// @brief clamp a single value. This function should be removed when std::clamp will be available
28-
template<class T>
29-
const T& stdclamp( const T& v, const T& lo, const T& hi )
26+
namespace sofa::type::pairwise
3027
{
31-
assert( !(hi < lo) );
32-
return (v < lo) ? lo : (hi < v) ? hi : v;
33-
}
3428

3529
/// @brief clamp all the values of a fixed_array to be within a given interval.
36-
template<class T, class TT=typename T::value_type, size_t TN=T::static_size>
37-
T clamp(const T& in, const TT& minValue, const TT& maxValue)
30+
template<class T, size_t TN=T::static_size>
31+
T clamp(const T& in, const typename T::value_type& minValue, const typename T::value_type& maxValue)
3832
{
3933
T result {};
4034
for(typename T::size_type i=0; i < typename T::size_type(TN); ++i)
4135
{
42-
result[i] = stdclamp(in[i], minValue, maxValue);
36+
result[i] = std::clamp(in[i], minValue, maxValue);
4337
}
4438
return result;
4539
}
4640

4741
/// @brief pairwise add of two fixed_array
48-
template<class T, class TT=typename T::value_type, size_t TN=T::static_size>
42+
template<class T, size_t TN=T::static_size>
4943
constexpr T operator+(const T& l, const T& r)
5044
{
5145
T result {};
@@ -57,7 +51,7 @@ constexpr T operator+(const T& l, const T& r)
5751
}
5852

5953
/// @brief pairwise subtract of two fixed_array
60-
template<class T, class TT=typename T::value_type, size_t TN=T::static_size>
54+
template<class T, size_t TN=T::static_size>
6155
constexpr T operator-(const T& l, const T& r)
6256
{
6357
T result {};
@@ -69,7 +63,7 @@ constexpr T operator-(const T& l, const T& r)
6963
}
7064

7165
/// @brief multiply from l the r components.
72-
template<class T, class TT=typename T::value_type, size_t TN=T::static_size>
66+
template<class T, size_t TN=T::static_size>
7367
T operator*(const T& r, const typename T::value_type& f)
7468
{
7569
T result {};
@@ -81,7 +75,7 @@ T operator*(const T& r, const typename T::value_type& f)
8175
}
8276

8377
/// @brief multiply from l the r components.
84-
template<class T, class TT=typename T::value_type, size_t TN=T::static_size>
78+
template<class T, size_t TN=T::static_size>
8579
T operator/(const T& r, const typename T::value_type& f)
8680
{
8781
T result {};

0 commit comments

Comments
 (0)