Commit d8fee1f4 authored by Alexis Girault's avatar Alexis Girault

ENH: Divide SceneObject & CollidingObject

Colliding geometry is only in CollidingObject.

To do this, we also had to :
- have PbdObject inherit CollidingObject (in the future
there should not be a distinct object class just for Pbd :
there should just be dynamical objects that can use
different models, like Pbd or FEM)
- remove useless checks when creating interactions: even
two colliding objects (not dynamic, aka static) could
be interacting if they are both controlled by devices
parent 85470771
......@@ -47,14 +47,6 @@ InteractionPair::InteractionPair(std::shared_ptr<CollidingObject> A,
return;
}
// Check that at least one object is not static
if (A->getType() == SceneObject::Type::Static &&
B->getType() == SceneObject::Type::Static)
{
LOG(WARNING) << "InteractionPair error: can not create interaction between two static objects.";
//return;
}
// Collision Detection
std::shared_ptr<CollisionDetection> CD = CollisionDetection::make_collision_detection(CDType, A, B, m_colData);
if (CD == nullptr)
......@@ -65,28 +57,28 @@ InteractionPair::InteractionPair(std::shared_ptr<CollidingObject> A,
// Collision Handling A
std::shared_ptr<CollisionHandling> CHA;
if (A->getType() != SceneObject::Type::Static)
if(CHAType != CollisionHandling::Type::None)
{
CHA = CollisionHandling::make_collision_handling(CHAType, CollisionHandling::Side::A, m_colData, A, B);
if (CHA == nullptr)
{
LOG(WARNING) << "InteractionPair error: can not instantiate collision handling for '"
CHA = CollisionHandling::make_collision_handling(CHAType, CollisionHandling::Side::A, m_colData, A, B);
if (CHA == nullptr)
{
LOG(WARNING) << "InteractionPair error: can not instantiate collision handling for '"
<< A->getName() << "' object.";
return;
}
return;
}
}
// Collision Handling B
std::shared_ptr<CollisionHandling> CHB;
if (B->getType() != SceneObject::Type::Static)
if(CHBType != CollisionHandling::Type::None)
{
CHB = CollisionHandling::make_collision_handling(CHBType, CollisionHandling::Side::B, m_colData, B, A);
if (CHB == nullptr)
{
LOG(WARNING) << "InteractionPair error: can not instantiate collision handling for '"
CHB = CollisionHandling::make_collision_handling(CHBType, CollisionHandling::Side::B, m_colData, B, A);
if (CHB == nullptr)
{
LOG(WARNING) << "InteractionPair error: can not instantiate collision handling for '"
<< B->getName() << "' object.";
return;
}
return;
}
}
// Init interactionPair
......
......@@ -40,7 +40,7 @@ public:
///
CollidingObject(std::string name) : SceneObject(name)
{
m_type = SceneObject::Type::Static;
m_type = Type::Colliding;
}
///
......
......@@ -48,7 +48,7 @@ public:
///
DeformableObject(std::string name) : DynamicObject(name)
{
m_type = SceneObject::Type::Deformable;
m_type = Type::Deformable;
}
///
......
#ifndef IMSTKPBDOBJECT_H
#define IMSTKPBDOBJECT_H
#include "imstkSceneObject.h"
#include "imstkCollidingObject.h"
#include "imstkPbdModel.h"
#include <stdarg.h>
......@@ -14,13 +14,13 @@ namespace imstk
///
/// \brief Base class for scene objects that move and/or deform
///
class PbdObject : public SceneObject
class PbdObject : public CollidingObject
{
public:
///
/// \brief
///
PbdObject(std::string name) : SceneObject(name)
PbdObject(std::string name) : CollidingObject(name)
{
m_type = SceneObject::Type::Deformable;
}
......@@ -108,4 +108,4 @@ protected:
} // imstk
#endif // IMSTKPBDOBJECT_H
\ No newline at end of file
#endif // IMSTKPBDOBJECT_H
......@@ -43,7 +43,7 @@ public:
///
RigidObject(std::string name) : DynamicObject(name)
{
m_type = SceneObject::Type::Rigid;
m_type = Type::Rigid;
}
///
......
......@@ -66,28 +66,4 @@ SceneObject::setName(const std::string& name)
m_name = name;
}
std::shared_ptr<Geometry>
SceneObject::getCollidingGeometry() const
{
return m_collidingGeometry;
}
void
SceneObject::setCollidingGeometry(std::shared_ptr<Geometry> geometry)
{
m_collidingGeometry = geometry;
}
std::shared_ptr<GeometryMap>
SceneObject::getCollidingToVisualMap() const
{
return m_collidingToVisualMap;
}
void
SceneObject::setCollidingToVisualMap(std::shared_ptr<GeometryMap> map)
{
m_collidingToVisualMap = map;
}
} // imstk
......@@ -45,8 +45,8 @@ class SceneObject
public:
enum class Type
{
Static,
Dynamic,
Visual,
Colliding,
Rigid,
Deformable,
VirtualCoupling
......@@ -57,7 +57,7 @@ public:
///
SceneObject(std::string name) : m_name(name)
{
SceneObject::Type::Static;
m_type = Type::Visual;
}
///
......@@ -87,30 +87,16 @@ public:
///
virtual std::shared_ptr<Geometry> getMasterGeometry() const;
///
/// \brief Set/Get the geometry used for collisions
///
std::shared_ptr<Geometry> getCollidingGeometry() const;
void setCollidingGeometry(std::shared_ptr<Geometry> geometry);
///
/// \brief Set/Get the Colliding-to-Visual map
///
std::shared_ptr<GeometryMap> getCollidingToVisualMap() const;
void setCollidingToVisualMap(std::shared_ptr<GeometryMap> map);
protected:
///
/// \brief Assigns the type of the object
///
void setType(Type type);
Type m_type = Type::Static; ///> Type of the scene object
Type m_type; ///> Type of the scene object
std::string m_name; ///> Custom name of the scene object
std::shared_ptr<Geometry> m_visualGeometry; ///> Geometry for rendering
std::shared_ptr<Geometry> m_collidingGeometry; ///> Geometry for collisions
std::shared_ptr<GeometryMap> m_collidingToVisualMap; ///> Maps transformations to visual geometry
};
using VisualObject = SceneObject;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment