Commit 85470771 authored by Alexis Girault's avatar Alexis Girault

ENH: Implement getMasterGeometry

Returns master geometry, defined master in the
geometry maps of the objects. Physic geometry will
drive the changes to the colliding geometry, which
will drive the changes to the visual geometry
parent fbc48bae
......@@ -36,6 +36,12 @@ CollidingObject::setCollidingGeometry(std::shared_ptr<Geometry> geometry)
m_collidingGeometry = geometry;
}
std::shared_ptr<Geometry>
CollidingObject::getMasterGeometry() const
{
return m_collidingGeometry;
}
  • @alexis-girault Shouldn't the master be the one defined in the map?

    Edited by Sreekanth Arikatla
  • Good question. It is indeed the same, but we know that it will always be collidingGeometry for collidingObject, visualGeometry for visualObject, etc. If you wanted to access it through the map instead of the object, there would be 2 issues:

    • it would add a call everytime the geometry is queried ( getMap()->getMaster() instead of getMasterGeometry() )
    • there can be multiple maps (for example for a dynamic object), so you would need to also implement which map is the 'Master' map, then access its master geometry
    Edited by Alexis Girault
  • getMap()->getMaster() is not a big overhead IMO. Yes for dynamic object we have multiple maps and the API should be clear on what do you mean by master.

  • You are right it's not much, but it's still more for the same result: master of dynamicObject will always be physicGeometry, master of collidingObject will always be collidingGeometry, master of visualObject will always be visualGeometry. If there was only one map I'd agree that it would maybe be clearer to just do what you are saying, but I think that since there can be multiple maps, then it's just the same. And for visualObject there are no maps so you'd return visualGeometry just the same, right?

    Edited by Alexis Girault
Please register or sign in to reply
std::shared_ptr<GeometryMap>
CollidingObject::getCollidingToVisualMap() const
{
......
......@@ -54,6 +54,11 @@ public:
std::shared_ptr<Geometry> getCollidingGeometry() const;
void setCollidingGeometry(std::shared_ptr<Geometry> geometry);
///
/// \brief Get the master geometry
///
virtual std::shared_ptr<Geometry> getMasterGeometry() const;
///
/// \brief
///
......
......@@ -36,6 +36,12 @@ DynamicObject::setPhysicsGeometry(std::shared_ptr<Geometry> geometry)
m_physicsGeometry = geometry;
}
std::shared_ptr<Geometry>
DynamicObject::getMasterGeometry() const
{
return m_physicsGeometry;
}
std::shared_ptr<GeometryMap>
DynamicObject::getPhysicsToCollidingMap() const
{
......
......@@ -48,6 +48,11 @@ public:
std::shared_ptr<Geometry> getPhysicsGeometry() const;
void setPhysicsGeometry(std::shared_ptr<Geometry> geometry);
///
/// \brief Get the master geometry
///
virtual std::shared_ptr<Geometry> getMasterGeometry() const;
///
/// \brief Set/Get the Physics-to-Collision map
///
......
......@@ -36,6 +36,12 @@ SceneObject::setVisualGeometry(std::shared_ptr<Geometry> geometry)
m_visualGeometry = geometry;
}
std::shared_ptr<Geometry>
SceneObject::getMasterGeometry() const
{
return m_visualGeometry;
}
const SceneObject::Type&
SceneObject::getType() const
{
......
......@@ -82,6 +82,11 @@ public:
std::shared_ptr<Geometry> getVisualGeometry() const;
void setVisualGeometry(std::shared_ptr<Geometry> geometry);
///
/// \brief Get the master geometry
///
virtual std::shared_ptr<Geometry> getMasterGeometry() const;
///
/// \brief Set/Get the geometry used for collisions
///
......
  • @alexis-girault This is a useful api but tricky one. The visual object returns its own geometry as the master which is not very useful or could be misleading? Shouldn't we do this through the maps that are defined?

  • getMasterGeometry() is a way to give the geometry that would need to be controlled by the controller, without the need for the controller to know the type of the object (aka no need to cast it based on the object type everytime). By just calling the virtual method getMasterGeometry() the controller will receive the geometry to transform, without having to worry about what geometry it is: the object will provide the correct geometry. Like explained in my previous comment on the discussion above, doing it through the maps would also work but would make it just more complex.

    Edited by Alexis Girault
  • @alexis-girault Based on our discussion offline, we are ok with this implementation.

  • Mentioned in commit 080d795f

    Toggle commit list
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