Skip to content

Commit d9357af

Browse files
committed
Use unique_ptr as input to Tube
1 parent e468f16 commit d9357af

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

examples/geometries/geometries.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ namespace {
9898
}
9999

100100
auto createTube(const std::shared_ptr<Material>& m1, const std::shared_ptr<LineBasicMaterial>& m2) {
101-
const auto curve = std::make_shared<CustomSineCurve>(0.5f);
102-
const auto geometry = TubeGeometry::create(curve, 32, 0.1f);
101+
auto curve = std::make_unique<CustomSineCurve>(0.5f);
102+
const auto geometry = TubeGeometry::create(std::move(curve), 32, 0.1f);
103103
auto mesh = Mesh::create(geometry, m1);
104104
const auto wire = LineSegments::create(WireframeGeometry::create(*geometry), m2);
105105
mesh->add(wire);

examples/geometries/tube_geometry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ namespace {
2424
};
2525

2626
auto makeTubeMesh() {
27-
const auto curve = std::make_shared<CustomSineCurve>(10.f);
27+
auto curve = std::make_unique<CustomSineCurve>(10.f);
2828

29-
const auto geometry = TubeGeometry::create(curve);
29+
const auto geometry = TubeGeometry::create(std::move(curve));
3030
const auto material = MeshBasicMaterial::create(
3131
{{"color", 0xff0000},
3232
{"side", Side::Double}});

include/threepp/geometries/TubeGeometry.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ namespace threepp {
2525
};
2626

2727
const float radius;
28-
const std::shared_ptr<Curve3> path;
28+
const std::unique_ptr<Curve3> path;
2929

3030
[[nodiscard]] std::string type() const override;
3131

3232
static std::shared_ptr<TubeGeometry> create(
33-
const std::shared_ptr<Curve3>& path,
33+
std::unique_ptr<Curve3> path,
3434
const Params& params);
3535

3636
static std::shared_ptr<TubeGeometry> create(
37-
const std::shared_ptr<Curve3>& path,
37+
std::unique_ptr<Curve3> path,
3838
unsigned int tubularSegments = 64,
3939
float radius = 1,
4040
unsigned int radialSegments = 16,
@@ -43,7 +43,7 @@ namespace threepp {
4343
private:
4444
FrenetFrames frames;
4545

46-
TubeGeometry(std::shared_ptr<Curve3> path, const Params& params);
46+
TubeGeometry(std::unique_ptr<Curve3> path, const Params& params);
4747
};
4848

4949
}// namespace threepp

src/threepp/geometries/TubeGeometry.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
using namespace threepp;
99

10-
TubeGeometry::TubeGeometry(std::shared_ptr<Curve3> path, const Params& params)
10+
TubeGeometry::TubeGeometry(std::unique_ptr<Curve3> path, const Params& params)
1111
: radius(params.radius), path(std::move(path)) {
1212

1313
this->frames = FrenetFrames::compute(*this->path, params.tubularSegments, params.closed);
@@ -135,14 +135,14 @@ std::string TubeGeometry::type() const {
135135
return "TubeGeometry";
136136
}
137137

138-
std::shared_ptr<TubeGeometry> TubeGeometry::create(const std::shared_ptr<Curve3>& path, const Params& params) {
138+
std::shared_ptr<TubeGeometry> TubeGeometry::create(std::unique_ptr<Curve3> path, const Params& params) {
139139

140-
return std::shared_ptr<TubeGeometry>(new TubeGeometry(path, params));
140+
return std::shared_ptr<TubeGeometry>(new TubeGeometry(std::move(path), params));
141141
}
142142

143-
std::shared_ptr<TubeGeometry> TubeGeometry::create(const std::shared_ptr<Curve3>& path, unsigned int tubularSegments, float radius, unsigned int radialSegments, bool closed) {
143+
std::shared_ptr<TubeGeometry> TubeGeometry::create(std::unique_ptr<Curve3> path, unsigned int tubularSegments, float radius, unsigned int radialSegments, bool closed) {
144144

145-
return create(path, Params(tubularSegments, radius, radialSegments, closed));
145+
return create(std::move(path), Params(tubularSegments, radius, radialSegments, closed));
146146
}
147147

148148
TubeGeometry::Params::Params(unsigned int tubularSegments, float radius, unsigned int radialSegments, bool closed)

0 commit comments

Comments
 (0)