Skip to content

Commit bbcc14a

Browse files
committed
Add function to set count of active points.
1 parent 86d6cdd commit bbcc14a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

render_pipeline/rpcore/util/circular_points_node.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ class RENDER_PIPELINE_DECL CircularPointsNode
3838

3939
void set_radius(float radius);
4040

41+
/**
42+
* Set a count of active points.
43+
*
44+
* Panda3D will draw points as given counts.
45+
* If @a count is -1, all points will be used.
46+
*/
47+
void set_active_point_count(int count);
48+
4149
private:
4250
struct Impl;
4351
std::shared_ptr<Impl> impl_;

src/rpcore/util/circular_points_node.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ struct CircularPointsNode::Impl
2525

2626
void upload_positions(void);
2727

28+
void set_active_point_count(int count);
29+
2830
bool dirty_ = true;
2931
NodePath points_np_;
3032
std::vector<LPoint3f> positions_;
@@ -86,6 +88,18 @@ void CircularPointsNode::Impl::upload_positions(void)
8688
dirty_ = false;
8789
}
8890

91+
void CircularPointsNode::Impl::set_active_point_count(int count)
92+
{
93+
if (count > positions_.size())
94+
{
95+
RPObject::global_warn("CircularPointsNode",
96+
fmt::format("Given count ({}) is bigger than the count of stored points ({}).", count, positions_.size()));
97+
return;
98+
}
99+
100+
DCAST(GeomNode, points_np_.node())->modify_geom(0)->modify_primitive(0)->modify_vertices(count);
101+
}
102+
89103
// ************************************************************************************************
90104
CircularPointsNode::CircularPointsNode(const std::string& name, const std::vector<LPoint3f>& positions, float radius,
91105
const std::string& effect_path, GeomEnums::UsageHint buffer_hint): impl_(std::make_unique<Impl>(name, positions,
@@ -147,4 +161,9 @@ void CircularPointsNode::set_radius(float radius)
147161
impl_->set_radius(radius);
148162
}
149163

164+
void CircularPointsNode::set_active_point_count(int count)
165+
{
166+
impl_->set_active_point_count(count);
167+
}
168+
150169
}

0 commit comments

Comments
 (0)