Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xpbd cloth and fascia simulation #1659

Merged
merged 36 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e6ac0e9
point deformer wip
lsltql Nov 28, 2023
5d0334c
zcloth deformer
lsltql Nov 30, 2023
28cb3ab
interior box-based surface deformer
lsltql Dec 1, 2023
d9764df
ccd eta control on prism bary computation
lsltql Dec 2, 2023
663cd4d
add bind-fail tag
lsltql Dec 2, 2023
36d1ddf
ccd and detangle with thickness wip
lsltql Dec 5, 2023
4e3356c
ZCloth deformer
lsltql Dec 5, 2023
03a280d
Merge branch 'master' of https://github.com/zenustech/zeno into XPBD
lsltql Dec 5, 2023
d524b20
Merge branch 'master' of https://github.com/zenustech/zeno into XPBD
lsltql Dec 5, 2023
96311b6
Merge branch 'master' of https://github.com/zenustech/zeno into XPBD
lsltql Dec 6, 2023
f10c499
Merge branch 'master' of https://github.com/zenustech/zeno into XPBD
lsltql Dec 7, 2023
8f68483
Merge branch 'master' of https://github.com/zenustech/zeno into XPBD
lsltql Dec 7, 2023
1be60e2
us floating-point zcloth binding-type tag
lsltql Dec 8, 2023
f85abe3
clean up code
lsltql Dec 8, 2023
2a8fe32
fix CCD crash with too large thickness
lsltql Dec 8, 2023
3105f52
save dcd constraint init memory
lsltql Dec 8, 2023
eff3c09
seperate dcd constraint type
lsltql Dec 8, 2023
ad7d244
dcd constraint for self collision
lsltql Dec 8, 2023
cb3eea0
Merge branch 'master' of https://github.com/zenustech/zeno into XPBD
lsltql Dec 10, 2023
5a51d40
pbd kinematic collision reorganize wip
lsltql Dec 10, 2023
bc8e980
Merge branch 'master' of https://github.com/zenustech/zeno into XPBD
lsltql Dec 11, 2023
0834ce2
Merge branch 'master' of https://github.com/zenustech/zeno into XPBD
lsltql Dec 11, 2023
8b8be93
kinematic boundary collision constraint
lsltql Dec 11, 2023
bd6f6d4
reverse back for collision trembling
lsltql Dec 12, 2023
2755bb6
compatible halfedge structure for non-manifold
lsltql Dec 12, 2023
c5599dc
affliate dcd explosion by increase boundary mass
lsltql Dec 12, 2023
de22bcc
add ccd accepted number of unsolved collision
lsltql Dec 12, 2023
1d6bbf0
print out number of non-manifold edges
lsltql Dec 12, 2023
ad769ae
fix friction force nan value
lsltql Dec 14, 2023
5dc05e5
collision group
lsltql Dec 14, 2023
4763156
fix new dcd constraints bumping bugs
lsltql Dec 15, 2023
d4b49a0
fix detangle2 bug for parallel seg tri pair
lsltql Dec 15, 2023
fbda832
make_pd might result in nan matrix
lsltql Dec 18, 2023
bd66888
fix detangle crash when no m and minv attr
lsltql Dec 19, 2023
c1f4a35
update stretch and pin constraints
lsltql Dec 19, 2023
3e67fa1
change eeccd a little bit
lsltql Dec 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 40 additions & 40 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
[ "$1" ] && [ $1 = Debug ] && flag="Debug" || flag="Release"
echo $flag
# [ "$1" ] && [ $1 = Debug ] && flag="Debug" || flag="Release"
# echo $flag

cmake -B build -DCMAKE_BUILD_TYPE=$flag \
-DZENO_MULTIPROCESS=ON \
-DZENO_WITH_zenvdb:BOOL=ON \
-DZENO_SYSTEM_OPENVDB=OFF \
-DZENO_WITH_ZenoFX:BOOL=ON \
-DZENO_ENABLE_OPTIX:BOOL=ON \
-DZENO_WITH_FBX:BOOL=ON \
-DZENO_WITH_Alembic:BOOL=ON \
-DZENO_WITH_MeshSubdiv:BOOL=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \

# cmake -B build -DCMAKE_BUILD_TYPE=Release \
# cmake -B build -DCMAKE_BUILD_TYPE=$flag \
# -DZENO_MULTIPROCESS=ON \
# -DZENO_WITH_zenvdb:BOOL=ON \
# -DZENO_SYSTEM_OPENVDB=OFF \
# -DZENO_WITH_ZenoFX:BOOL=ON \
# -DZENO_ENABLE_OPTIX:BOOL=ON \
# -DZENO_SYSTEM_OPENVDB=OFF \
# -DZENO_WITH_zenvdb:BOOL=ON \
# -DZENOFX_ENABLE_OPENVDB:BOOL=ON \
# -DZENOFX_ENABLE_LBVH:BOOL=ON \
# -DZENO_WITH_FastFLIP:BOOL=ON \
# -DZENO_WITH_FEM:BOOL=ON \
# -DZENO_WITH_Rigid:BOOL=ON \
# -DZENO_WITH_cgmesh:BOOL=ON \
# -DZENO_WITH_oldzenbase:BOOL=ON \
# -DZENO_WITH_TreeSketch:BOOL=ON \
# -DZENO_WITH_Skinning:BOOL=ON \
# -DZENO_WITH_Euler:BOOL=ON \
# -DZENO_WITH_Functional:BOOL=ON \
# -DZENO_WITH_LSystem:BOOL=ON \
# -DZENO_WITH_mesher:BOOL=ON \
# -DZENO_WITH_Alembic:BOOL=ON \
# -DZENO_WITH_FBX:BOOL=ON \
# -DZENO_WITH_DemBones:BOOL=ON \
# -DZENO_WITH_SampleModel:BOOL=ON \
# -DZENO_WITH_CalcGeometryUV:BOOL=ON \
# -DZENO_WITH_Alembic:BOOL=ON \
# -DZENO_WITH_MeshSubdiv:BOOL=ON \
# -DZENO_WITH_Audio:BOOL=ON \
# -DZENO_WITH_PBD:BOOL=ON \
# -DZENO_WITH_GUI:BOOL=ON \
# -DZENO_WITH_ImgCV:BOOL=ON \
# -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \

cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DZENO_WITH_ZenoFX:BOOL=ON \
-DZENO_ENABLE_OPTIX:BOOL=ON \
-DZENO_SYSTEM_OPENVDB=OFF \
-DZENO_WITH_zenvdb:BOOL=ON \
-DZENOFX_ENABLE_OPENVDB:BOOL=ON \
-DZENOFX_ENABLE_LBVH:BOOL=ON \
-DZENO_WITH_FastFLIP:BOOL=ON \
-DZENO_WITH_FEM:BOOL=ON \
-DZENO_WITH_Rigid:BOOL=ON \
-DZENO_WITH_cgmesh:BOOL=ON \
-DZENO_WITH_oldzenbase:BOOL=ON \
-DZENO_WITH_TreeSketch:BOOL=ON \
-DZENO_WITH_Skinning:BOOL=ON \
-DZENO_WITH_Euler:BOOL=ON \
-DZENO_WITH_Functional:BOOL=ON \
-DZENO_WITH_LSystem:BOOL=ON \
-DZENO_WITH_mesher:BOOL=ON \
-DZENO_WITH_Alembic:BOOL=ON \
-DZENO_WITH_FBX:BOOL=ON \
-DZENO_WITH_DemBones:BOOL=ON \
-DZENO_WITH_SampleModel:BOOL=ON \
-DZENO_WITH_CalcGeometryUV:BOOL=ON \
-DZENO_WITH_MeshSubdiv:BOOL=ON \
-DZENO_WITH_Audio:BOOL=ON \
-DZENO_WITH_PBD:BOOL=ON \
-DZENO_WITH_GUI:BOOL=ON \
-DZENO_WITH_ImgCV:BOOL=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON

cmake --build build --parallel $(nproc) \

# ln -s ./build/compile_commands.json ./
cp ./build/compile_commands.json ./
# cp ./build/compile_commands.json ./

rm -rf /var/tmp/OptixCache_$USER/
# rm -rf /var/tmp/OptixCache_$USER/
1 change: 1 addition & 0 deletions projects/CUDA/Structures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ struct ZenoParticles : IObjectClone<ZenoParticles> {
static constexpr auto s_surfVertTag = "surfVerts";
static constexpr auto s_surfHalfEdgeTag = "surfHalfEdges";
static constexpr auto s_tetHalfFacetTag = "tetHalfFacets";
static constexpr auto s_surfBoundaryEdgeTag = "surfBoundaryEdges";

ZenoParticles() = default;
~ZenoParticles() = default;
Expand Down
159 changes: 159 additions & 0 deletions projects/CUDA/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,165 @@ retrieve_bounding_volumes(Pol &pol, const TileVecT &vtemp,
return ret;
}


template <int codim, typename Pol, typename TileVecT>
zs::Vector<typename ZenoParticles::lbvh_t::Box>
retrieve_bounding_volumes(Pol &pol, const TileVecT &vtemp,
float thickness = 0.f,
const zs::SmallString &xTag = "xn") {
using namespace zs;
using bv_t = typename ZenoParticles::lbvh_t::Box;
// static_assert(codim >= 1 && codim <= 4, "invalid co-dimension!\n");
constexpr auto space = Pol::exec_tag::value;
#if ZS_ENABLE_CUDA && defined(__CUDACC__)
// ZS_LAMBDA -> __device__
static_assert(space == execspace_e::cuda,
"specialized policy and compiler not match");
#else
static_assert(space != execspace_e::cuda,
"specialized policy and compiler not match");
#endif
size_t nm_elms = vtemp.size() / codim;

Vector<bv_t> ret{vtemp.get_allocator(), nm_elms};
pol(zs::range(nm_elms), [bvs = proxy<space>(ret),
vtemp = proxy<space>({}, vtemp), xTag,
thickness] ZS_LAMBDA(int ei) mutable {
auto x0 = vtemp.template pack<3>(xTag, ei * codim);
bv_t bv{x0, x0};
for (int d = 1; d != codim; ++d)
merge(bv, vtemp.template pack<3>(xTag, ei * codim + d));
bv._min -= thickness / 2;
bv._max += thickness / 2;
bvs[ei] = bv;
});
return ret;
}

template <typename Pol, typename TileVecT>
zs::Vector<typename ZenoParticles::lbvh_t::Box>
retrieve_bounding_volumes(Pol &pol, const TileVecT &vtemp,
float radius = 0.f,
const zs::SmallString &xTag = "xn") {
using namespace zs;
using bv_t = typename ZenoParticles::lbvh_t::Box;
constexpr auto space = Pol::exec_tag::value;
#if ZS_ENABLE_CUDA && defined(__CUDACC__)
// ZS_LAMBDA -> __device__
static_assert(space == execspace_e::cuda,
"specialized policy and compiler not match");
#else
static_assert(space != execspace_e::cuda,
"specialized policy and compiler not match");
#endif
Vector<bv_t> ret{vtemp.get_allocator(), vtemp.size()};
pol(zs::range(vtemp.size()), [bvs = proxy<space>(ret),
vtemp = proxy<space>({}, vtemp),
xTag = xTag,
radius = radius] ZS_LAMBDA(int vi) mutable {
auto x0 = vtemp.template pack<3>(xTag, vi);
bv_t bv{x0, x0};
bv._min -= radius;
bv._max += radius;
bvs[vi] = bv;
});
return ret;
}

template <typename Pol, typename TileVecT>
void retrieve_bounding_volumes(Pol &pol, const TileVecT &vtemp,
zs::Vector<ZenoParticles::lbvh_t::Box>& ret,
float radius = 0.f,
const zs::SmallString &xTag = "xn") {
using namespace zs;
using bv_t = typename ZenoParticles::lbvh_t::Box;
constexpr auto space = Pol::exec_tag::value;
#if ZS_ENABLE_CUDA && defined(__CUDACC__)
// ZS_LAMBDA -> __device__
static_assert(space == execspace_e::cuda,
"specialized policy and compiler not match");
#else
static_assert(space != execspace_e::cuda,
"specialized policy and compiler not match");
#endif
// Vector<bv_t> ret{vtemp.get_allocator(), vtemp.size()};
ret.resize(vtemp.size());
pol(zs::range(vtemp.size()), [bvs = proxy<space>(ret),
vtemp = proxy<space>({}, vtemp),
xTag = xTag,
radius = radius] ZS_LAMBDA(int vi) mutable {
auto x0 = vtemp.template pack<3>(xTag, vi);
bv_t bv{x0, x0};
bv._min -= radius;
bv._max += radius;
bvs[vi] = bv;
});
// return ret;
}

template <typename Pol, typename TileVecT>
zs::Vector<typename ZenoParticles::lbvh_t::Box>
retrieve_bounding_volumes(Pol &pol, const TileVecT &vtemp,
const zs::SmallString &rTag = "r",
const zs::SmallString &xTag = "xn") {
using namespace zs;
using bv_t = typename ZenoParticles::lbvh_t::Box;
constexpr auto space = Pol::exec_tag::value;
#if ZS_ENABLE_CUDA && defined(__CUDACC__)
// ZS_LAMBDA -> __device__
static_assert(space == execspace_e::cuda,
"specialized policy and compiler not match");
#else
static_assert(space != execspace_e::cuda,
"specialized policy and compiler not match");
#endif
Vector<bv_t> ret{vtemp.get_allocator(), vtemp.size()};
pol(zs::range(vtemp.size()), [bvs = proxy<space>(ret),
vtemp = proxy<space>({}, vtemp),
rTag,
xTag] ZS_LAMBDA(int vi) mutable {
auto x0 = vtemp.template pack<3>(xTag, vi);
bv_t bv{x0, x0};
auto radius = vtemp(rTag,vi);
bv._min -= radius;
bv._max += radius;
bvs[vi] = bv;
});
return ret;
}

template <typename Pol, typename TileVecT>
void retrieve_bounding_volumes(Pol &pol, const TileVecT &vtemp,
zs::Vector<typename ZenoParticles::lbvh_t::Box>& ret,
const zs::SmallString &rTag = "r",
const zs::SmallString &xTag = "xn") {
using namespace zs;
using bv_t = typename ZenoParticles::lbvh_t::Box;
constexpr auto space = Pol::exec_tag::value;
#if ZS_ENABLE_CUDA && defined(__CUDACC__)
// ZS_LAMBDA -> __device__
static_assert(space == execspace_e::cuda,
"specialized policy and compiler not match");
#else
static_assert(space != execspace_e::cuda,
"specialized policy and compiler not match");
#endif
// Vector<bv_t> ret{vtemp.get_allocator(), vtemp.size()};
ret.resize(vtemp.size());
pol(zs::range(vtemp.size()), [bvs = proxy<space>(ret),
vtemp = proxy<space>({}, vtemp),
rTag,
xTag] ZS_LAMBDA(int vi) mutable {
auto x0 = vtemp.template pack<3>(xTag, vi);
bv_t bv{x0, x0};
auto radius = vtemp(rTag,vi);
bv._min -= radius;
bv._max += radius;
bvs[vi] = bv;
});
// return ret;
}

// for ccd
template <typename Pol, typename TileVecT0, typename TileVecT1, int codim = 3>
zs::Vector<typename ZenoParticles::lbvh_t::Box> retrieve_bounding_volumes(
Expand Down
7 changes: 3 additions & 4 deletions projects/CuLagrange/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ target_sources(zeno PRIVATE

# pbd
target_sources(zeno PRIVATE
pbd/Constraints.cu
# pbd/SelfCollision.cu
pbd/ConstraintsBuilder.cu
pbd/ConstraintsSolver.cu
pbd/KinematicCollision.cu
# pbd/Pipeline.cu
)

# fem-cloth
Expand Down Expand Up @@ -114,7 +113,7 @@ target_sources(zeno PRIVATE
geometry/kernel/compute_characteristic_length.hpp
geometry/kernel/topology.hpp
geometry/kernel/calculate_facet_normal.hpp
geometry/kernel/calculate_bisector_normal.hpp
# geometry/kernel/calculate_bisector_normal.hpp
geometry/kernel/tiled_vector_ops.hpp
geometry/kernel/intersection.hpp
geometry/SolveLaplacian.cu
Expand Down
13 changes: 13 additions & 0 deletions projects/CuLagrange/fem/Ccds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ ptccd(VecT p, VecT t0, VecT t1, VecT t2, VecT dp, VecT dt0, VecT dt1, VecT dt2,
T gap = eta * (dist2_cur - thickness * thickness) / (dist_cur + thickness);
T toc_prev = toc;
toc = tStart;

if(gap < 0)
return true;

int iter = 0;
while (++iter < 1000000) {
// while (true) {
Expand Down Expand Up @@ -137,6 +141,9 @@ eeccd(VecT ea0, VecT ea1, VecT eb0, VecT eb1, VecT dea0, VecT dea1, VecT deb0,

T dist2_cur = dist2_ee_unclassified(ea0, ea1, eb0, eb1);
T dFunc = dist2_cur - thickness * thickness;
// suspecious code, check twice
if(dFunc <= 0)
return true;
if (dFunc <= 0) {
// since we ensured other place that all dist smaller than dHat are
// positive, this must be some far away nearly parallel edges
Expand All @@ -151,10 +158,16 @@ eeccd(VecT ea0, VecT ea1, VecT eb0, VecT eb1, VecT dea0, VecT dea1, VecT deb0,
}
dFunc = dist2_cur - thickness * thickness;
}


T dist_cur = zs::sqrt(dist2_cur);
T gap = eta * dFunc / (dist_cur + thickness);
T toc_prev = toc;
toc = tStart;

if(dFunc <= 0)
return true;

int iter = 0;
while (++iter < 1000000) {
// while (true) {
Expand Down
2 changes: 1 addition & 1 deletion projects/CuLagrange/fem/ClothCollision.cu
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void ClothSystem::findBoundaryCellCollisionConstraints(zs::CudaExecutionPolicy &
biNrm *= -1;
return biNrm;
};
if (!COLLISION_UTILS::pointProjectsInsideTriangle(t0, t1, t2, p))
if (!COLLISION_UTILS::vertex_projects_inside_triangle(t0, t1, t2, p))
for (int i = 0; i != 3; ++i) {
auto bisector_normal = get_bisector_orient(i);
if (bisector_normal.dot(seg) < 0)
Expand Down
Loading
Loading