Skip to content

Commit cd8ac89

Browse files
committed
Add get-size functions to SurfaceTool
1 parent 08e6cd1 commit cd8ac89

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

doc/classes/SurfaceTool.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@
163163
Returns the format for custom [param channel_index] (currently up to 4). Returns [constant CUSTOM_MAX] if this custom channel is unused.
164164
</description>
165165
</method>
166+
<method name="get_num_indices" qualifiers="const">
167+
<return type="int" />
168+
<description>
169+
Returns the current number of indices.
170+
</description>
171+
</method>
172+
<method name="get_num_vertices" qualifiers="const">
173+
<return type="int" />
174+
<description>
175+
Returns the current number of vertices.
176+
</description>
177+
</method>
166178
<method name="get_primitive_type" qualifiers="const">
167179
<return type="int" enum="Mesh.PrimitiveType" />
168180
<description>

scene/resources/surface_tool.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ void SurfaceTool::begin(Mesh::PrimitiveType p_primitive) {
223223
first = true;
224224
}
225225

226+
int SurfaceTool::get_num_vertices() const {
227+
return vertex_array.size();
228+
}
229+
230+
int SurfaceTool::get_num_indices() const {
231+
return index_array.size();
232+
}
233+
226234
void SurfaceTool::add_vertex(const Vector3 &p_vertex) {
227235
ERR_FAIL_COND(!begun);
228236

@@ -1346,6 +1354,8 @@ void SurfaceTool::_bind_methods() {
13461354
ClassDB::bind_method(D_METHOD("get_custom_format", "channel_index"), &SurfaceTool::get_custom_format);
13471355

13481356
ClassDB::bind_method(D_METHOD("begin", "primitive"), &SurfaceTool::begin);
1357+
ClassDB::bind_method(D_METHOD("get_num_vertices"), &SurfaceTool::get_num_vertices);
1358+
ClassDB::bind_method(D_METHOD("get_num_indices"), &SurfaceTool::get_num_indices);
13491359

13501360
ClassDB::bind_method(D_METHOD("add_vertex", "vertex"), &SurfaceTool::add_vertex);
13511361
ClassDB::bind_method(D_METHOD("set_color", "color"), &SurfaceTool::set_color);

scene/resources/surface_tool.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ class SurfaceTool : public RefCounted {
209209
void set_weights(const Vector<float> &p_weights);
210210
void set_smooth_group(uint32_t p_group);
211211

212+
int get_num_vertices() const;
213+
int get_num_indices() const;
214+
212215
void add_vertex(const Vector3 &p_vertex);
213216

214217
void add_triangle_fan(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uvs = Vector<Vector2>(), const Vector<Color> &p_colors = Vector<Color>(), const Vector<Vector2> &p_uv2s = Vector<Vector2>(), const Vector<Vector3> &p_normals = Vector<Vector3>(), const Vector<Plane> &p_tangents = Vector<Plane>());

0 commit comments

Comments
 (0)