Skip to content

Commit

Permalink
#6167: Update the curve vertex renderable when the underlying curve i…
Browse files Browse the repository at this point in the history
…s changed
  • Loading branch information
codereader committed Nov 17, 2022
1 parent 93c804a commit 07295a8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion radiantcore/entity/curve/Curve.cpp
Expand Up @@ -133,7 +133,7 @@ void Curve::curveChanged()
{
// Recalculate the tesselation
tesselate();
_renderCurve.queueUpdate();
updateRenderable();

// Recalculate bounds
_bounds = AABB();
Expand Down
4 changes: 1 addition & 3 deletions radiantcore/entity/curve/Curve.h
Expand Up @@ -23,8 +23,6 @@ class Curve :
// A list of iterators, used for communication with the CurveEditInstance
typedef std::vector<ControlPoints::iterator> IteratorList;

typedef std::function<void()> CurveChangedCallback;

protected:
ControlPoints _controlPoints;
ControlPoints _controlPointsTransformed;
Expand All @@ -45,7 +43,7 @@ class Curve :
const AABB& getBounds() const;

/// Signal emitted when curve changes
sigc::signal<void> signal_curveChanged()
sigc::signal<void>& signal_curveChanged()
{
return _sigCurveChanged;
}
Expand Down
18 changes: 15 additions & 3 deletions radiantcore/entity/curve/RenderableCurveVertices.h
@@ -1,5 +1,6 @@
#pragma once

#include <sigc++/connection.h>
#include "Curve.h"
#include "CurveEditInstance.h"
#include "render/RenderableGeometry.h"
Expand All @@ -11,16 +12,27 @@ class RenderableCurveVertices :
public render::RenderableGeometry
{
private:
const Curve& _curve;
Curve& _curve;
const CurveEditInstance& _instance;
bool _updateNeeded;
sigc::connection _curveChangedHandler;

public:
RenderableCurveVertices(const Curve& curve, const CurveEditInstance& instance) :
RenderableCurveVertices(Curve& curve, const CurveEditInstance& instance) :
_curve(curve),
_instance(instance),
_updateNeeded(true)
{}
{
// Update this renderable when the curve vertices are changed
_curveChangedHandler = _curve.signal_curveChanged().connect(
sigc::mem_fun(*this, &RenderableCurveVertices::queueUpdate)
);
}

~RenderableCurveVertices() override
{
_curveChangedHandler.disconnect();
}

void queueUpdate()
{
Expand Down

0 comments on commit 07295a8

Please sign in to comment.