Skip to content

Commit

Permalink
git subrepo clone --branch=master https://github.com/V-Sekai/precondi…
Browse files Browse the repository at this point in the history
…tioner-for-cloth-and-deformable-body-simulation.git thirdparty/preconditioner-for-cloth-and-deformable-body-simulation

subrepo:
  subdir:   "thirdparty/preconditioner-for-cloth-and-deformable-body-simulation"
  merged:   "bf3d095"
upstream:
  origin:   "https://github.com/V-Sekai/preconditioner-for-cloth-and-deformable-body-simulation.git"
  branch:   "master"
  commit:   "bf3d095"
git-subrepo:
  version:  "0.4.6"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "110b9eb"
  • Loading branch information
fire committed Sep 5, 2023
1 parent c83e463 commit e69fe94
Show file tree
Hide file tree
Showing 22 changed files with 7,513 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme
;
[subrepo]
remote = https://github.com/V-Sekai/preconditioner-for-cloth-and-deformable-body-simulation.git
branch = master
commit = bf3d095a8636fa541990e38c1fce796515b7b119
parent = c83e46325ad184347f259ac9ce3c43388d32f6e9
method = merge
cmdver = 0.4.6
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (C) 2002 - 2022,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# preconditioner-for-cloth-and-deformable-body-simulation

This is a mirror of https://wanghmin.github.io/publications.html

## Entry point

See `SeSchwarzPreconditioner.h` for entry points.
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2002 - 2022,
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of its contributors may not be used to endorse or promote
// products derived from this software without specific prior written
// permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma once

#include "SeMath.h"
#include <cfloat>

SE_NAMESPACE_BEGIN

/*************************************************************************
****************************** SeAabb ******************************
*************************************************************************/

/**
* @brief Axis-align Bounding Box.
*/
template<typename VecType> struct SeAabb
{
static_assert(std::is_floating_point<typename VecType::value_type>::value, "Only support floating type currently.");

public:

//! @brief Default constructor.
SeAabb() : Lower(FLT_MAX), Upper(-FLT_MAX) {}

//! @brief Constructed by a given point.
SeAabb(const VecType & Point) : Lower(Point), Upper(Point) {}

//! @brief Constructed by a paired points explicitly.
explicit SeAabb(const VecType & P1, const VecType & P2) : Lower(Math::Min(P1, P2)), Upper(Math::Max(P1, P2)) {}

//! @brief Constructed by a paired points explicitly.
explicit SeAabb(const VecType & P1, const VecType & P2, const VecType & P3) : Lower(Math::Min(P1, P2, P3)), Upper(Math::Max(P1, P2, P3)) {}




public:

SeAabb<VecType> operator+(const SeAabb<VecType> & Other) const
{
return SeAabb<VecType>(Math::Min(Lower, Other.Lower), Math::Max(Upper, Other.Upper));
}

SeAabb<VecType> operator+(const VecType & Point) const
{
return SeAabb<VecType>(Math::Min(Lower, Point), Math::Max(Upper, Point));
}

void operator+=(const SeAabb<VecType> & Other)
{
Lower = Math::Min(Lower, Other.Lower); Upper = Math::Max(Upper, Other.Upper);
}

void operator+=(const VecType & Point)
{
Lower = Math::Min(Lower, Point); Upper = Math::Max(Upper, Point);
}

void Enlarge(float Amount)
{
Lower -= Amount; Upper += Amount;
}

VecType Center() const
{
return Math::Average(Lower, Upper);
}

VecType Extent() const
{
return Upper - Lower;
}

public:

VecType Lower, Upper;
};


/*************************************************************************
*********************** IsInside<AABB-AABB> ************************
*************************************************************************/

template<typename VecT>
static SE_INLINE bool IsContain(const SeAabb<VecT>& aabb, const VecT& P)
{
const int componentCount = VecT::Elements;
for (int i = 0; i < componentCount; i++)
{
if (P[i]<aabb.Lower[i] || P[i]>aabb.Upper[i])
{
return false;
}
}
return true;

}
template<typename VecT>
static SE_INLINE bool IsContain(const SeAabb<VecT>& aabb, const VecT& P,float radium)
{
auto enlargedAabb = aabb;
enlargedAabb.Upper += radium;
enlargedAabb.Lower -= radium;
return IsContain(aabb, enlargedAabb);
}

template<>
static SE_INLINE bool IsContain(const SeAabb<Float2>& aabb, const Float2& P)
{
return !((aabb.Upper.x < P.x) || (aabb.Upper.y < P.y) ||
(aabb.Lower.x > P.x) || (aabb.Lower.y > P.y));
}

template<>
static SE_INLINE bool IsContain(const SeAabb<Float3>& aabb, const Float3& P)
{
return !((aabb.Upper.x < P.x) || (aabb.Upper.y < P.y) || (aabb.Upper.z < P.z) ||
(aabb.Lower.x > P.x) || (aabb.Lower.y > P.y) || (aabb.Lower.z > P.z));
}

/*************************************************************************
*********************** IsInside<AABB-Line> ************************
*************************************************************************/

template<typename VecT>
static bool IsIntersect(const SeAabb<VecT>& aabb, const VecT& Pa, const VecT& Pb, const VecT& iv);

template<typename VecT>
static bool IsIntersect(const SeAabb<VecT>& aabb, const VecT& Pa, const VecT& Pb);


template<>
static SE_INLINE bool IsIntersect(const SeAabb<Float3>& aabb, const Float3& Pa, const Float3& Pb)
{
Float3 Dir = Float3(Pb - Pa);

if (Dir.x == 0.0f) Dir.x = 1e-6f;
if (Dir.y == 0.0f) Dir.y = 1e-6f;
if (Dir.z == 0.0f) Dir.z = 1e-6f;

Float3 invDir = 1.0f / Dir;
Float3 Left = Float3(aabb.Lower - Pa) * invDir;
Float3 Right = Float3(aabb.Upper - Pa) * invDir;

Float2 T1 = Float2(Math::Min(Left.x, Right.x), Math::Max(Left.x, Right.x));
Float2 T2 = Float2(Math::Min(Left.y, Right.y), Math::Max(Left.y, Right.y));
Float2 T3 = Float2(Math::Min(Left.z, Right.z), Math::Max(Left.z, Right.z));

float range0 = Math::Max(T1.x, T2.x, T3.x, 0.0f);
float range1 = Math::Min(T1.y, T2.y, T3.y, 1.0f);

return range0 < range1;
}


template<typename VecT>
static SE_INLINE bool IsOverlap(const SeAabb<VecT>& aabb, const SeAabb<VecT>& P) { return false; }


SE_NAMESPACE_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2002 - 2022,
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of its contributors may not be used to endorse or promote
// products derived from this software without specific prior written
// permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma once

#include "SeMathSimd.h"

#include "SeAabb.h"

#include <limits>

SE_NAMESPACE_BEGIN

/*************************************************************************
****************************** SeAabb ******************************
*************************************************************************/

/**
* @brief Axis-align Bounding Box.
*/

template<> struct SeAabb<Simd3f>
{

public:

//! @brief Default constructor.
SeAabb() : Lower(FLT_MAX), Upper(-FLT_MAX) {}

//! @brief Constructed by a given point.
SeAabb(const Simd3f & Point) : Lower(Point), Upper(Point) {}

//! @brief Constructed by a paired points explicitly.
explicit SeAabb(const Simd3f & P1, const Simd3f & P2) : Lower(Math::Min(P1, P2)), Upper(Math::Max(P1, P2)) {}

public:

SeAabb operator+(const SeAabb & Other) const
{
return SeAabb(Math::Min(Lower, Other.Lower), Math::Max(Upper, Other.Upper));
}

SeAabb operator+(const Simd3f & Point) const
{
return SeAabb(Math::Min(Lower, Point), Math::Max(Upper, Point));
}

void operator += (const SeAabb & Other)
{
Lower = Math::Min(Lower, Other.Lower); Upper = Math::Max(Upper, Other.Upper);
}

void operator += (const Simd3f & Point)
{
Lower = Math::Min(Lower, Point); Upper = Math::Max(Upper, Point);
}

void Enlarge(float Amount)
{
Lower -= Amount; Upper += Amount;
}

Simd3f Center() const
{
return Math::Average(Lower, Upper);
}

Simd3f Extent() const
{
return Upper - Lower;
}

public:

Simd3f Lower, Upper;
};



template<>
static SE_INLINE bool IsContain(const SeAabb<Simd3f>& aabb, const Simd3f& P)
{
return !((aabb.Upper.x < P.x) || (aabb.Upper.y < P.y) || (aabb.Upper.z < P.z) ||
(aabb.Lower.x > P.x) || (aabb.Lower.y > P.y) || (aabb.Lower.z > P.z));
}

template<>
static SE_INLINE bool IsContain(const SeAabb<Simd3f>& aabb, const Simd3f& P, float radium)
{
return !((aabb.Upper.x < P.x - radium) || (aabb.Upper.y < P.y - radium) || (aabb.Upper.z < P.z - radium) ||
(aabb.Lower.x > P.x + radium) || (aabb.Lower.y > P.y + radium) || (aabb.Lower.z > P.z + radium));
}

template<>
static SE_INLINE bool IsOverlap(const SeAabb<Simd3f>& aabb, const SeAabb<Simd3f>& P)
{
return !((aabb.Upper.x < P.Lower.x) || (aabb.Upper.y < P.Lower.y) || (aabb.Upper.z < P.Lower.z) ||
(aabb.Lower.x > P.Upper.x) || (aabb.Lower.y > P.Upper.y) || (aabb.Lower.z > P.Upper.z));
}


template<>
static SE_INLINE bool IsIntersect(const SeAabb<Simd3f>& aabb, const Simd3f& Pa, const Simd3f& Pb)
{
Simd3f Dir = Simd3f(Pb - Pa);

if (Dir.x == 0.0f) Dir.x = 1e-6f;
if (Dir.y == 0.0f) Dir.y = 1e-6f;
if (Dir.z == 0.0f) Dir.z = 1e-6f;

Simd3f invDir = 1.0f / Dir;
Simd3f Left = Simd3f(aabb.Lower - Pa) * invDir;
Simd3f Right = Simd3f(aabb.Upper - Pa) * invDir;

Float2 T1 = Float2(Math::Min(Left.x, Right.x), Math::Max(Left.x, Right.x));
Float2 T2 = Float2(Math::Min(Left.y, Right.y), Math::Max(Left.y, Right.y));
Float2 T3 = Float2(Math::Min(Left.z, Right.z), Math::Max(Left.z, Right.z));

float range0 = Math::Max(T1.x, T2.x, T3.x, 0.0f);
float range1 = Math::Min(T1.y, T2.y, T3.y, 1.0f);

return range0 < range1;
}

SE_NAMESPACE_END
Loading

0 comments on commit e69fe94

Please sign in to comment.