Skip to content

Commit

Permalink
Testing shared_ptr on Ground Plane.
Browse files Browse the repository at this point in the history
  • Loading branch information
croudyj committed Jul 26, 2023
1 parent b369cf3 commit 090961c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/bindings/bnd_3dm_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ BND_RenderSettings::~BND_RenderSettings()

void BND_RenderSettings::Construct()
{
m_ground_plane = new BND_File3dmGroundPlane (&m_render_settings->GroundPlane());
m_ground_plane = new BND_File3dmGroundPlane (std::shared_ptr<ON_GroundPlane>(&m_render_settings->GroundPlane()));
m_safe_frame = new BND_File3dmSafeFrame (&m_render_settings->SafeFrame());
m_dithering = new BND_File3dmDithering (&m_render_settings->Dithering());
m_skylight = new BND_File3dmSkylight (&m_render_settings->Skylight());
Expand Down
10 changes: 4 additions & 6 deletions src/bindings/bnd_ground_plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@

BND_File3dmGroundPlane::BND_File3dmGroundPlane()
{
_gp = new ON_GroundPlane;
_owned = true;
_gp = std::make_shared<ON_GroundPlane>();
}

BND_File3dmGroundPlane::BND_File3dmGroundPlane(const BND_File3dmGroundPlane& gp)
{
_gp = new ON_GroundPlane(*gp._gp);
_owned = true;
_gp = gp._gp;
}

BND_File3dmGroundPlane::BND_File3dmGroundPlane(ON_GroundPlane* gp)
: _gp(gp)
BND_File3dmGroundPlane::BND_File3dmGroundPlane(std::shared_ptr<ON_GroundPlane> gp)
{
_gp = gp;
}

#if defined(ON_PYTHON_COMPILE)
Expand Down
6 changes: 2 additions & 4 deletions src/bindings/bnd_ground_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ void initGroundPlaneBindings(void* m);
class BND_File3dmGroundPlane
{
private:
ON_GroundPlane* _gp = nullptr;
bool _owned = false;
std::shared_ptr<ON_GroundPlane> _gp;

public:
BND_File3dmGroundPlane();
BND_File3dmGroundPlane(ON_GroundPlane* gp);
BND_File3dmGroundPlane(std::shared_ptr<ON_GroundPlane> gp);
BND_File3dmGroundPlane(const BND_File3dmGroundPlane& gp);
~BND_File3dmGroundPlane() { if (_owned) delete _gp; }

bool GetEnabled(void) const { return _gp->Enabled(); }
void SetEnabled(bool v) { _gp->SetEnabled(v); }
Expand Down

0 comments on commit 090961c

Please sign in to comment.