diff --git a/src/shared/geometries/transform_shape.h b/src/shared/geometries/transform_shape.h index 2eab0e12f3..5fc0ee31e3 100644 --- a/src/shared/geometries/transform_shape.h +++ b/src/shared/geometries/transform_shape.h @@ -72,13 +72,36 @@ class TransformShape : public BaseShapeType protected: Transform transform_; + /// Returns the AABB of the rotated underlying shape's AABB + /// ⚠️ It is not the tight fit AABB of the underlying shape + /// But at least it encloses the underlying shape fully virtual BoundingBox findBounds() override { BoundingBox original_bound = BaseShapeType::findBounds(); - return BoundingBox(transform_.shiftFrameStationToBase(original_bound.first_), - transform_.shiftFrameStationToBase(original_bound.second_)); + Vecd bb_min = Vecd::Constant(MaxReal); + Vecd bb_max = Vecd::Constant(-MaxReal); + for (auto x : {original_bound.first_.x(), original_bound.second_.x()}) + { + for (auto y : {original_bound.first_.y(), original_bound.second_.y()}) + { + if constexpr (Dimensions == 3) + { + for (auto z : {original_bound.first_.z(), original_bound.second_.z()}) + { + bb_min = bb_min.cwiseMin(transform_.shiftFrameStationToBase(Vecd(x, y, z))); + bb_max = bb_max.cwiseMax(transform_.shiftFrameStationToBase(Vecd(x, y, z))); + } + } + else + { + bb_min = bb_min.cwiseMin(transform_.shiftFrameStationToBase(Vecd(x, y))); + bb_max = bb_max.cwiseMax(transform_.shiftFrameStationToBase(Vecd(x, y))); + } + } + } + return BoundingBox(bb_min, bb_max); }; }; } // namespace SPH -#endif // TRANSFORM_SHAPE_H \ No newline at end of file +#endif // TRANSFORM_SHAPE_H diff --git a/src/shared/shared_ck/particle_dynamics/general_dynamics/general_reduce_ck.hpp b/src/shared/shared_ck/particle_dynamics/general_dynamics/general_reduce_ck.hpp index b768132bb9..60cd56a8ba 100644 --- a/src/shared/shared_ck/particle_dynamics/general_dynamics/general_reduce_ck.hpp +++ b/src/shared/shared_ck/particle_dynamics/general_dynamics/general_reduce_ck.hpp @@ -16,7 +16,7 @@ template template VariableNormCK::ReduceKernel:: ReduceKernel(const ExecutionPolicy &ex_policy, EncloserType &encloser) - : variable_(encloser.dv_variable_->template DelegatedDataField(ex_policy)) {} + : variable_(encloser.dv_variable_->DelegatedDataField(ex_policy)) {} //=================================================================================================// template TotalKineticEnergyCK::ReduceKernel::