Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sreekanth Arikatla
iMSTK
Commits
a7158781
Commit
a7158781
authored
Aug 01, 2017
by
Sreekanth Arikatla
Browse files
Merge branch 'addSupportForPointSet' into 'master'
Add support for point set See merge request !202
parents
4098bd5e
4c47e8b4
Changes
47
Hide whitespace changes
Inline
Side-by-side
Base/Collision/CollisionDetection/imstkCollisionDetection.cpp
View file @
a7158781
...
...
@@ -24,11 +24,11 @@
#include
"imstkUnidirectionalPlaneToSphereCD.h"
#include
"imstkBidirectionalPlaneToSphereCD.h"
#include
"imstkSphereToSphereCD.h"
#include
"imstk
Mesh
ToSphereCD.h"
#include
"imstk
Mesh
ToPlaneCD.h"
#include
"imstk
PointSet
ToSphereCD.h"
#include
"imstk
PointSet
ToPlaneCD.h"
#include
"imstkMeshToMeshCD.h"
#include
"imstkSphereCylinderCD.h"
#include
"imstk
Mesh
ToSpherePickingCD.h"
#include
"imstk
PointSet
ToSpherePickingCD.h"
#include
"imstkCollidingObject.h"
#include
"imstkPlane.h"
...
...
@@ -107,9 +107,9 @@ CollisionDetection::make_collision_detection(const Type& type,
return
std
::
make_shared
<
SphereCylinderCD
>
(
sphere
,
cylinder
,
colData
);
}
break
;
case
Type
::
Mesh
ToSphere
:
case
Type
::
PointSet
ToSphere
:
{
auto
mesh
=
std
::
dynamic_pointer_cast
<
Mesh
>
(
objA
->
getCollidingGeometry
());
auto
mesh
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
objA
->
getCollidingGeometry
());
auto
sphere
=
std
::
dynamic_pointer_cast
<
Sphere
>
(
objB
->
getCollidingGeometry
());
// Geometries check
...
...
@@ -119,12 +119,12 @@ CollisionDetection::make_collision_detection(const Type& type,
<<
"invalid object geometries for SphereToSphere collision detection."
;
return
nullptr
;
}
return
std
::
make_shared
<
Mesh
ToSphereCD
>
(
mesh
,
sphere
,
colData
);
return
std
::
make_shared
<
PointSet
ToSphereCD
>
(
mesh
,
sphere
,
colData
);
}
break
;
case
Type
::
Mesh
ToPlane
:
case
Type
::
PointSet
ToPlane
:
{
auto
mesh
=
std
::
dynamic_pointer_cast
<
Mesh
>
(
objA
->
getCollidingGeometry
());
auto
mesh
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
objA
->
getCollidingGeometry
());
auto
plane
=
std
::
dynamic_pointer_cast
<
Plane
>
(
objB
->
getCollidingGeometry
());
// Geometries check
...
...
@@ -134,7 +134,7 @@ CollisionDetection::make_collision_detection(const Type& type,
<<
"invalid object geometries for SphereToSphere collision detection."
;
return
nullptr
;
}
return
std
::
make_shared
<
Mesh
ToPlaneCD
>
(
mesh
,
plane
,
colData
);
return
std
::
make_shared
<
PointSet
ToPlaneCD
>
(
mesh
,
plane
,
colData
);
}
break
;
case
Type
::
MeshToMesh
:
...
...
@@ -152,9 +152,9 @@ CollisionDetection::make_collision_detection(const Type& type,
return
std
::
make_shared
<
MeshToMeshCD
>
(
meshA
,
meshB
,
colData
);
}
break
;
case
Type
::
Mesh
ToSpherePicking
:
case
Type
::
PointSet
ToSpherePicking
:
{
auto
mesh
=
std
::
dynamic_pointer_cast
<
Mesh
>
(
objA
->
getCollidingGeometry
());
auto
mesh
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
objA
->
getCollidingGeometry
());
auto
sphere
=
std
::
dynamic_pointer_cast
<
Sphere
>
(
objB
->
getCollidingGeometry
());
// Geometries check
...
...
@@ -164,7 +164,7 @@ CollisionDetection::make_collision_detection(const Type& type,
<<
"invalid object geometries for SphereToSphere collision detection."
;
return
nullptr
;
}
return
std
::
make_shared
<
Mesh
ToSpherePickingCD
>
(
mesh
,
sphere
,
colData
);
return
std
::
make_shared
<
PointSet
ToSpherePickingCD
>
(
mesh
,
sphere
,
colData
);
}
break
;
default:
...
...
Base/Collision/CollisionDetection/imstkCollisionDetection.h
View file @
a7158781
...
...
@@ -47,11 +47,11 @@ public:
BidirectionalPlaneToSphere
,
SphereToCylinder
,
SphereToSphere
,
Mesh
ToSphere
,
Mesh
ToPlane
,
PointSet
ToSphere
,
PointSet
ToPlane
,
MeshToMesh
,
Mesh
ToCapsule
,
Mesh
ToSpherePicking
PointSet
ToCapsule
,
PointSet
ToSpherePicking
};
///
...
...
Base/Collision/CollisionDetection/imstk
Mesh
ToCapsuleCD.cpp
→
Base/Collision/CollisionDetection/imstk
PointSet
ToCapsuleCD.cpp
View file @
a7158781
...
...
@@ -19,11 +19,11 @@
=========================================================================*/
#include
"imstk
Mesh
ToCapsuleCD.h"
#include
"imstk
PointSet
ToCapsuleCD.h"
#include
"imstkCollisionData.h"
#include
"imstkCapsule.h"
#include
"imstk
Mesh
.h"
#include
"imstk
PointSet
.h"
#include
"imstkMath.h"
#include
<g3log/g3log.hpp>
...
...
@@ -31,7 +31,7 @@
namespace
imstk
{
void
Mesh
ToCapsuleCD
::
computeCollisionData
()
PointSet
ToCapsuleCD
::
computeCollisionData
()
{
// Clear collisionData
m_colData
.
clearAll
();
...
...
@@ -50,7 +50,7 @@ MeshToCapsuleCD::computeCollisionData()
auto
pDotp0
=
p
.
dot
(
p0
);
size_t
nodeId
=
0
;
for
(
const
auto
&
q
:
m_
mesh
->
getVertexPositions
())
for
(
const
auto
&
q
:
m_
pointSet
->
getVertexPositions
())
{
// First, check collision with bounding sphere
if
((
mid
-
q
).
norm
()
>
(
radius
+
length
*
0.5
))
...
...
Base/Collision/CollisionDetection/imstk
Mesh
ToCapsuleCD.h
→
Base/Collision/CollisionDetection/imstk
PointSet
ToCapsuleCD.h
View file @
a7158781
...
...
@@ -19,8 +19,8 @@
=========================================================================*/
#ifndef imstk
Mesh
ToCapsuleCD_h
#define imstk
Mesh
ToCapsuleCD_h
#ifndef imstk
PointSet
ToCapsuleCD_h
#define imstk
PointSet
ToCapsuleCD_h
#include
<memory>
...
...
@@ -28,34 +28,34 @@
namespace
imstk
{
class
Mesh
;
class
PointSet
;
class
Capsule
;
class
CollisionData
;
///
/// \class
Mesh
ToCapsuleCD
/// \class
PointSet
ToCapsuleCD
///
/// \brief
Mesh
to Capsule collision detection
/// \brief
PointSet
to Capsule collision detection
///
class
Mesh
ToCapsuleCD
:
public
CollisionDetection
class
PointSet
ToCapsuleCD
:
public
CollisionDetection
{
public:
///
/// \brief Constructor
///
Mesh
ToCapsuleCD
(
std
::
shared_ptr
<
Mesh
>
mesh
,
std
::
shared_ptr
<
Capsule
>
capsule
,
CollisionData
&
colData
)
:
CollisionDetection
(
CollisionDetection
::
Type
::
Mesh
ToCapsule
,
PointSet
ToCapsuleCD
(
std
::
shared_ptr
<
PointSet
>
pointSet
,
std
::
shared_ptr
<
Capsule
>
capsule
,
CollisionData
&
colData
)
:
CollisionDetection
(
CollisionDetection
::
Type
::
PointSet
ToCapsule
,
colData
),
m_
mesh
(
mesh
),
m_
pointSet
(
pointSet
),
m_capsule
(
capsule
){}
///
/// \brief Destructor
///
~
Mesh
ToCapsuleCD
()
=
default
;
~
PointSet
ToCapsuleCD
()
=
default
;
///
/// \brief Detect collision and compute collision data
...
...
@@ -64,9 +64,9 @@ public:
private:
std
::
shared_ptr
<
Mesh
>
m_mesh
;
///>
Mesh
std
::
shared_ptr
<
Capsule
>
m_capsule
;
///> Capsule
std
::
shared_ptr
<
PointSet
>
m_pointSet
;
///>
PointSet
std
::
shared_ptr
<
Capsule
>
m_capsule
;
///> Capsule
};
}
#endif // ifndef imstkMeshToCapsuleCD_h
\ No newline at end of file
#endif // ifndef imstkPointSetToCapsuleCD_h
\ No newline at end of file
Base/Collision/CollisionDetection/imstk
Mesh
ToPlaneCD.cpp
→
Base/Collision/CollisionDetection/imstk
PointSet
ToPlaneCD.cpp
View file @
a7158781
...
...
@@ -19,19 +19,19 @@
=========================================================================*/
#include
"imstk
Mesh
ToPlaneCD.h"
#include
"imstk
PointSet
ToPlaneCD.h"
#include
"imstkCollidingObject.h"
#include
"imstkCollisionData.h"
#include
"imstkPlane.h"
#include
"imstk
Mesh
.h"
#include
"imstk
PointSet
.h"
#include
<g3log/g3log.hpp>
namespace
imstk
{
void
Mesh
ToPlaneCD
::
computeCollisionData
()
PointSet
ToPlaneCD
::
computeCollisionData
()
{
// Clear collisionData
m_colData
.
clearAll
();
...
...
@@ -43,7 +43,7 @@ MeshToPlaneCD::computeCollisionData()
auto
planeNormal
=
m_plane
->
getNormal
();
size_t
nodeId
=
0
;
for
(
const
auto
&
p
:
m_
mesh
->
getVertexPositions
())
for
(
const
auto
&
p
:
m_
pointSet
->
getVertexPositions
())
{
auto
peneDistance
=
(
planePos
-
p
).
dot
(
planeNormal
);
if
(
peneDistance
<=
0.0
)
...
...
Base/Collision/CollisionDetection/imstk
Mesh
ToPlaneCD.h
→
Base/Collision/CollisionDetection/imstk
PointSet
ToPlaneCD.h
View file @
a7158781
...
...
@@ -19,8 +19,8 @@
=========================================================================*/
#ifndef imstk
Mesh
ToPlaneCD_h
#define imstk
Mesh
ToPlaneCD_h
#ifndef imstk
PointSet
ToPlaneCD_h
#define imstk
PointSet
ToPlaneCD_h
#include
<memory>
...
...
@@ -28,34 +28,34 @@
namespace
imstk
{
class
Mesh
;
class
PointSet
;
class
Plane
;
class
CollisionData
;
///
/// \class
Mesh
ToPlaneCD
/// \class
PointSet
ToPlaneCD
///
/// \brief
Mesh
to plane collision detection
/// \brief
PointSet
to plane collision detection
///
class
Mesh
ToPlaneCD
:
public
CollisionDetection
class
PointSet
ToPlaneCD
:
public
CollisionDetection
{
public:
///
/// \brief Constructor
///
Mesh
ToPlaneCD
(
std
::
shared_ptr
<
Mesh
>
mesh
,
std
::
shared_ptr
<
Plane
>
plane
,
CollisionData
&
colData
)
:
CollisionDetection
(
CollisionDetection
::
Type
::
Mesh
ToSphere
,
PointSet
ToPlaneCD
(
std
::
shared_ptr
<
PointSet
>
pointSet
,
std
::
shared_ptr
<
Plane
>
plane
,
CollisionData
&
colData
)
:
CollisionDetection
(
CollisionDetection
::
Type
::
PointSet
ToSphere
,
colData
),
m_
mesh
(
mesh
),
m_
pointSet
(
pointSet
),
m_plane
(
plane
){}
///
/// \brief Destructor
///
~
Mesh
ToPlaneCD
()
=
default
;
~
PointSet
ToPlaneCD
()
=
default
;
///
/// \brief Detect collision and compute collision data
...
...
@@ -64,9 +64,9 @@ public:
private:
std
::
shared_ptr
<
Mesh
>
m_mesh
;
///>
Mesh
std
::
shared_ptr
<
Plane
>
m_plane
;
///> Plane
std
::
shared_ptr
<
PointSet
>
m_pointSet
;
///>
PointSet
std
::
shared_ptr
<
Plane
>
m_plane
;
///> Plane
};
}
#endif // ifndef imstk
Mesh
ToPlaneCD_h
#endif // ifndef imstk
PointSet
ToPlaneCD_h
Base/Collision/CollisionDetection/imstk
Mesh
ToSphereCD.cpp
→
Base/Collision/CollisionDetection/imstk
PointSet
ToSphereCD.cpp
View file @
a7158781
...
...
@@ -19,19 +19,19 @@
=========================================================================*/
#include
"imstk
Mesh
ToSphereCD.h"
#include
"imstk
PointSet
ToSphereCD.h"
#include
"imstkCollidingObject.h"
#include
"imstkCollisionData.h"
#include
"imstkSphere.h"
#include
"imstk
Mesh
.h"
#include
"imstk
PointSet
.h"
#include
<g3log/g3log.hpp>
namespace
imstk
{
void
Mesh
ToSphereCD
::
computeCollisionData
()
PointSet
ToSphereCD
::
computeCollisionData
()
{
// Clear collisionData
m_colData
.
clearAll
();
...
...
@@ -41,7 +41,7 @@ MeshToSphereCD::computeCollisionData()
auto
radius
=
m_sphere
->
getRadius
();
size_t
nodeId
=
0
;
for
(
const
auto
&
p
:
m_
mesh
->
getVertexPositions
())
for
(
const
auto
&
p
:
m_
pointSet
->
getVertexPositions
())
{
auto
dist
=
(
spherePos
-
p
).
norm
();
if
(
dist
<=
radius
)
...
...
Base/Collision/CollisionDetection/imstk
Mesh
ToSphereCD.h
→
Base/Collision/CollisionDetection/imstk
PointSet
ToSphereCD.h
View file @
a7158781
...
...
@@ -19,8 +19,8 @@
=========================================================================*/
#ifndef imstk
Mesh
ToSphereCD_h
#define imstk
Mesh
ToSphereCD_h
#ifndef imstk
PointSet
ToSphereCD_h
#define imstk
PointSet
ToSphereCD_h
#include
<memory>
...
...
@@ -28,34 +28,34 @@
namespace
imstk
{
class
Mesh
;
class
PointSet
;
class
Sphere
;
class
CollisionData
;
///
/// \class
Mesh
ToSphereCD
/// \class
PointSet
ToSphereCD
///
/// \brief
Mesh
to sphere collision detection
/// \brief
PointSet
to sphere collision detection
///
class
Mesh
ToSphereCD
:
public
CollisionDetection
class
PointSet
ToSphereCD
:
public
CollisionDetection
{
public:
///
/// \brief Constructor
///
Mesh
ToSphereCD
(
std
::
shared_ptr
<
Mesh
>
mesh
,
std
::
shared_ptr
<
Sphere
>
sphere
,
CollisionData
&
colData
)
:
CollisionDetection
(
CollisionDetection
::
Type
::
Mesh
ToSphere
,
PointSet
ToSphereCD
(
std
::
shared_ptr
<
PointSet
>
pointSet
,
std
::
shared_ptr
<
Sphere
>
sphere
,
CollisionData
&
colData
)
:
CollisionDetection
(
CollisionDetection
::
Type
::
PointSet
ToSphere
,
colData
),
m_
mesh
(
mesh
),
m_
pointSet
(
pointSet
),
m_sphere
(
sphere
){}
///
/// \brief Destructor
///
~
Mesh
ToSphereCD
()
=
default
;
~
PointSet
ToSphereCD
()
=
default
;
///
/// \brief Detect collision and compute collision data
...
...
@@ -64,9 +64,9 @@ public:
private:
std
::
shared_ptr
<
Mesh
>
m_mesh
;
///>
Mesh
std
::
shared_ptr
<
Sphere
>
m_sphere
;
///> Sphere
std
::
shared_ptr
<
PointSet
>
m_pointSet
;
///>
PointSet
std
::
shared_ptr
<
Sphere
>
m_sphere
;
///> Sphere
};
}
#endif // ifndef imstk
Mesh
ToSphereCD_h
#endif // ifndef imstk
PointSet
ToSphereCD_h
Base/Collision/CollisionDetection/imstk
Mesh
ToSpherePickingCD.cpp
→
Base/Collision/CollisionDetection/imstk
PointSet
ToSpherePickingCD.cpp
View file @
a7158781
...
...
@@ -19,15 +19,15 @@ limitations under the License.
=========================================================================*/
#include
"imstk
Mesh
ToSpherePickingCD.h"
#include
"imstk
PointSet
ToSpherePickingCD.h"
#include
"imstkCollisionData.h"
#include
"imstk
Mesh
.h"
#include
"imstk
PointSet
.h"
#include
"imstkSphere.h"
namespace
imstk
{
void
Mesh
ToSpherePickingCD
::
computeCollisionData
()
PointSet
ToSpherePickingCD
::
computeCollisionData
()
{
// Clear collisionData
m_colData
.
clearAll
();
...
...
@@ -42,7 +42,7 @@ MeshToSpherePickingCD::computeCollisionData()
auto
radius
=
m_sphere
->
getRadius
()
*
m_sphere
->
getScaling
();
size_t
nodeId
=
0
;
for
(
const
auto
&
p
:
m_
mesh
->
getVertexPositions
())
for
(
const
auto
&
p
:
m_
pointSet
->
getVertexPositions
())
{
auto
dist
=
(
spherePos
-
p
).
norm
();
if
(
dist
<=
radius
)
...
...
Base/Collision/CollisionDetection/imstk
Mesh
ToSpherePickingCD.h
→
Base/Collision/CollisionDetection/imstk
PointSet
ToSpherePickingCD.h
View file @
a7158781
...
...
@@ -19,8 +19,8 @@
=========================================================================*/
#ifndef imstk
Mesh
ToSpherePickingCD_h
#define imstk
Mesh
ToSpherePickingCD_h
#ifndef imstk
PointSet
ToSpherePickingCD_h
#define imstk
PointSet
ToSpherePickingCD_h
#include
<memory>
...
...
@@ -29,34 +29,34 @@
namespace
imstk
{
class
Mesh
;
class
PointSet
;
class
Sphere
;
class
CollisionData
;
///
/// \class
Mesh
ToSpherePickingCD
/// \class
PointSet
ToSpherePickingCD
///
/// \brief
Mesh
to sphere collision detection while picking
/// \brief
PointSet
to sphere collision detection while picking
///
class
Mesh
ToSpherePickingCD
:
public
CollisionDetection
class
PointSet
ToSpherePickingCD
:
public
CollisionDetection
{
public:
///
/// \brief Constructor
///
Mesh
ToSpherePickingCD
(
std
::
shared_ptr
<
Mesh
>
mesh
,
std
::
shared_ptr
<
Sphere
>
sphere
,
CollisionData
&
colData
)
:
CollisionDetection
(
CollisionDetection
::
Type
::
Mesh
ToSphere
,
PointSet
ToSpherePickingCD
(
std
::
shared_ptr
<
PointSet
>
pointSet
,
std
::
shared_ptr
<
Sphere
>
sphere
,
CollisionData
&
colData
)
:
CollisionDetection
(
CollisionDetection
::
Type
::
PointSet
ToSphere
,
colData
),
m_
mesh
(
mesh
),
m_
pointSet
(
pointSet
),
m_sphere
(
sphere
){}
///
/// \brief Destructor
///
~
Mesh
ToSpherePickingCD
()
=
default
;
~
PointSet
ToSpherePickingCD
()
=
default
;
///
/// \brief Detect collision and compute collision data
...
...
@@ -70,12 +70,12 @@ public:
const
unsigned
int
buttonId
=
0
){
m_deviceTracker
=
devTracker
;
}
private:
std
::
shared_ptr
<
Mesh
>
m_mesh
;
///> Mesh
std
::
shared_ptr
<
Sphere
>
m_sphere
;
///> Sphere
std
::
shared_ptr
<
PointSet
>
m_pointSet
;
///> PointSet
std
::
shared_ptr
<
Sphere
>
m_sphere
;
///> Sphere
std
::
shared_ptr
<
imstk
::
DeviceTracker
>
m_deviceTracker
;
///> Device tracker to get the button status
unsigned
int
m_buttonId
=
0
;
///> button id
unsigned
int
m_buttonId
=
0
;
///> button id
};
}
#endif // ifndef imstk
Mesh
ToSphereCD_h
#endif // ifndef imstk
PointSet
ToSphereCD_h
Base/Collision/CollisionHandling/imstkPickingCH.cpp
View file @
a7158781
...
...
@@ -58,7 +58,7 @@ PickingCH::addPickConstraints(std::shared_ptr<DeformableObject> deformableObj)
const
auto
&
Uprev
=
deformableObj
->
getDisplacements
();
const
auto
&
Vprev
=
deformableObj
->
getVelocities
();
auto
PhysTetMesh
=
std
::
dynamic_pointer_cast
<
Mesh
>
(
deformableObj
->
getPhysicsGeometry
());
auto
PhysTetMesh
=
std
::
dynamic_pointer_cast
<
PointSet
>
(
deformableObj
->
getPhysicsGeometry
());
auto
dT
=
std
::
dynamic_pointer_cast
<
FEMDeformableBodyModel
>
(
m_object
->
getDynamicalModel
())
->
getTimeIntegrator
()
->
getTimestepSize
();
// If collision data, append LPC constraints
...
...
Base/Collision/imstkPbdInteractionPair.cpp
View file @
a7158781
...
...
@@ -32,8 +32,8 @@ PbdInteractionPair::doBroadPhaseCollision()
{
auto
g1
=
first
->
getCollidingGeometry
();
auto
g2
=
second
->
getCollidingGeometry
();
auto
mesh1
=
std
::
static_pointer_cast
<
Mesh
>
(
g1
);
auto
mesh2
=
std
::
static_pointer_cast
<
Mesh
>
(
g2
);
auto
mesh1
=
std
::
static_pointer_cast
<
PointSet
>
(
g1
);
auto
mesh2
=
std
::
static_pointer_cast
<
PointSet
>
(
g2
);
Vec3d
min1
,
max1
;
mesh1
->
computeBoundingBox
(
min1
,
max1
);
...
...
@@ -93,7 +93,7 @@ PbdInteractionPair::doNarrowPhaseCollision()
p2
[
0
],
p2
[
1
],
p2
[
2
],
prox1
,
prox2
))
{
auto
c
=
std
::
make_shared
<
PbdPointTriangleConstraint
>
();
c
->
initConstraint
(
dynaModel1
,
map1
->
getMapIdx
(
i
)
,
c
->
initConstraint
(
dynaModel1
,
i
,
dynaModel2
,
map2
->
getMapIdx
(
e
[
0
]),
map2
->
getMapIdx
(
e
[
1
]),
map2
->
getMapIdx
(
e
[
2
]));
m_collisionConstraints
.
push_back
(
c
);
}
...
...
@@ -166,6 +166,38 @@ PbdInteractionPair::doNarrowPhaseCollision()
}
}
}
else
if
(
g1
->
getType
()
==
Geometry
::
Type
::
PointSet
)
{
auto
mesh1
=
std
::
static_pointer_cast
<
PointSet
>
(
g1
);
// brute force, use BVH or spatial grid would be much better
// point
for
(
size_t
i
=
0
;
i
<
mesh1
->
getNumVertices
();
++
i
)
{
const
auto
p
=
mesh1
->
getVertexPosition
(
i
);
auto
elements
=
mesh2
->
getTrianglesVertices
();
for
(
size_t
j
=
0
;
j
<
elements
.
size
();
++
j
)
{
auto
&
e
=
elements
[
j
];
const
Vec3d
p0
=
mesh2
->
getVertexPosition
(
e
[
0
]);
const
Vec3d
p1
=
mesh2
->
getVertexPosition
(
e
[
1
]);
const
Vec3d
p2
=
mesh2
->
getVertexPosition
(
e
[
2
]);
if
(
testPointToTriAABB
(
p
[
0
],
p
[
1
],
p
[
2
],
p0
[
0
],
p0
[
1
],
p0
[
2
],
p1
[
0
],
p1
[
1
],
p1
[
2
],
p2
[
0
],
p2
[
1
],
p2
[
2
],
prox1
,
prox2
))
{
auto
c
=
std
::
make_shared
<
PbdPointTriangleConstraint
>
();
auto
mappedIndex1
=
(
map1
)
?
map1
->
getMapIdx
(
i
)
:
i
;
c
->
initConstraint
(
dynaModel1
,
mappedIndex1
,
dynaModel2
,
map2
->
getMapIdx
(
e
[
0
]),
map2
->
getMapIdx
(
e
[
1
]),
map2
->
getMapIdx
(
e
[
2
]));
m_collisionConstraints
.
push_back
(
c
);
}
}
}
}
else
{
auto
mesh1
=
std
::
static_pointer_cast
<
SurfaceMesh
>
(
g1
);
...
...
@@ -175,7 +207,7 @@ PbdInteractionPair::doNarrowPhaseCollision()
for
(
size_t
i
=
0
;
i
<
mesh1
->
getNumVertices
();
++
i
)
{
const
Vec3d
p
=
mesh1
->
getVertexPosition
(
i
);
std
::
vector
<
SurfaceMesh
::
TriangleArray
>
elements
=
mesh2
->
getTrianglesVertices
();
auto
elements
=
mesh2
->
getTrianglesVertices
();
for
(
size_t
j
=
0
;
j
<
elements
.
size
();
++
j
)
{
...
...
Base/Constraint/PbdConstraints/imstkPbdConstantDensityConstraint.cpp
View file @
a7158781
...
...
@@ -41,10 +41,6 @@ PbdConstantDensityConstraint::initConstraint(PbdModel& model, const double k)
m_numNeighbors
.
resize
(
np
);
m_deltaPositions
.
resize
(
np
);
m_neighbors
.
resize
(
np
*
m_maxNumNeighbors
);
m_xPosIndexes
.
resize
(
np
);
m_yPosIndexes
.
resize
(
np
);
m_zPosIndexes
.
resize
(
np
);
}
bool
...
...
@@ -101,7 +97,7 @@ PbdConstantDensityConstraint::gradSpiky(const Vec3d &pi, const Vec3d &pj)
}
inline
void
PbdConstantDensityConstraint
::
clearNeighbors
(
const
size_t
&
np
)
PbdConstantDensityConstraint
::
clearNeighbors
(
const
size_t
np
)
{
m_numNeighbors
.
clear
();
m_neighbors
.
clear
();
...
...
@@ -111,7 +107,7 @@ PbdConstantDensityConstraint::clearNeighbors(const size_t &np)
inline
void
PbdConstantDensityConstraint
::
updateNeighborsBruteForce
(
const
Vec3d
&
pi
,
const
size_t
&
index
,
const
size_t
index
,
const
StdVectorOfVec3d
&
positions
)
{
const
double
neighborRadius
=
m_maxDist
;
...
...
@@ -141,7 +137,7 @@ PbdConstantDensityConstraint::updateNeighborsBruteForce(const Vec3d &pi,