Skip to content

Commit

Permalink
trying to clone capsule geometries
Browse files Browse the repository at this point in the history
Signed-off-by: Ashton Larkin <[email protected]>
  • Loading branch information
adlarkin committed Sep 20, 2021
1 parent f5b07ea commit 9d87388
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
26 changes: 26 additions & 0 deletions include/ignition/rendering/base/BaseCapsule.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef IGNITION_RENDERING_BASECAPSULE_HH_
#define IGNITION_RENDERING_BASECAPSULE_HH_

#include <ignition/common/Console.hh>

#include "ignition/rendering/Capsule.hh"
#include "ignition/rendering/base/BaseObject.hh"

Expand Down Expand Up @@ -50,6 +52,9 @@ namespace ignition
// Documentation inherited
public: virtual double Length() const override;

// Documentation inherited
public: virtual GeometryPtr Clone() const override;

/// \brief Radius of the capsule
protected: double radius = 0.5;

Expand Down Expand Up @@ -103,6 +108,27 @@ namespace ignition
{
return this->length;
}

/////////////////////////////////////////////////
template <class T>
GeometryPtr BaseCapsule<T>::Clone() const
{
if (!this->Scene())
{
ignerr << "Cloning a Capsule failed because the capsule to be "
<< "cloned does not belong to a scene.\n";
return nullptr;
}

auto result = this->Scene()->CreateCapsule();
if (result)
{
result->SetRadius(this->Radius());
result->SetLength(this->Length());
}

return result;
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions include/ignition/rendering/base/BaseGeometry.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace ignition
public: virtual void SetMaterial(MaterialPtr _material,
bool _unique = true) override = 0;

// Documentation inherited
public: virtual GeometryPtr Clone() const override;

// Documentation inherited
Expand Down Expand Up @@ -98,6 +99,7 @@ namespace ignition
template <class T>
GeometryPtr BaseGeometry<T>::Clone() const
{
ignwarn << "Clone functionality for Geometry does not exist yet.\n";
return nullptr;
}

Expand Down
2 changes: 1 addition & 1 deletion include/ignition/rendering/base/BaseMesh.hh
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ namespace ignition
{
if (!this->Scene())
{
ignerr << "Cloning a geometry failed because the geometry to be "
ignerr << "Cloning a mesh failed because the mesh to be "
<< "cloned does not belong to a scene.\n";
return nullptr;
}
Expand Down

0 comments on commit 9d87388

Please sign in to comment.