Repository: godotengine/godot (language: cpp)

Issue:
CSG function _update_shape() is not documented
**Your Godot version:**
3.2.1 stable official, on Windows 10

**Issue description:**
[CSGShape _update_shape()](https://github.com/godotengine/godot/blob/master/modules/csg/csg_shape.cpp) is not documented.

When dealing with CSG from code, it looks like this is a very important function (examples of people using and discussing about this function [here](https://github.com/godotengine/godot/issues/29275), [here](https://github.com/godotengine/godot/issues/33138) and [here](https://github.com/godotengine/godot/issues/19232)) . Without it, many things are not possible, so why it is not documented?

**URL to the documentation page (if already existing):**
https://docs.godotengine.org/en/3.2/classes/class_csgshape.html?rtd_search=_update_shape#class-csgshape-method-get-meshes

*Bugsquad edit: Transferred to the main repository as this issue pertains to the class reference.*


Discussion / hints:
The method is not documented because it's considered to be internal (`_` prefix is used to determine whether the method is going to be exposed). But it's still possible to call these kind of methods, see godotengine/godot-proposals#2285.

So, it's possible to expose the method publicly instead, something like `force_update_shape()` like in ray cast nodes, but we'd have to be sure that it won't unexpectedly break or crash the engine if used this way.
> The method is not documented because it's considered to be internal (`_` prefix is used to determine whether the method is going to be exposed). But it's still possible to call these kind of methods, see [godotengine/godot-proposals#2285](https://github.com/godotengine/godot-proposals/issues/2285).
> 
> So, it's possible to expose the method publicly instead, something like `force_update_shape()` like in ray cast nodes, but we'd have to be sure that it won't unexpectedly break or crash the engine if used this way.

Hum, Ok, I understand, but I would like to have the funcionality available somehow. So, with #46258 , will this be possible?
Yes, I think #46258 would make it easier to use to get immediate results from CSG operations. But I don't know what you personally need this for, so adding `force_update_shape()` may be enough in fact.

Note that this is just my 2 cents, I haven't used those CSG features myself extensively to fully understand the existing limitations.

@Xrayez You are too fast 😀

> Yes, I think #46258 would make it easier to use to get immediate results from CSG operations.

@Saitodepaula Keep in mind that `_update_shape()` is intended to be used in idle time and I have not removed this limitation.
But if you just need the final mesh, then it will be possible with #46258 


The methods seems to never be called. It should be removed.

EDIT:
Nevermind, it is used. idk how I missed it.

Fix patch:
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 12d807be46b4..a3f4727e2b76 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -208,13 +208,13 @@ float CSGShape3D::get_snap() const {
 
 void CSGShape3D::_make_dirty(bool p_parent_removing) {
 	if ((p_parent_removing || is_root_shape()) && !dirty) {
-		callable_mp(this, &CSGShape3D::_update_shape).call_deferred(); // Must be deferred; otherwise, is_root_shape() will use the previous parent.
+		callable_mp(this, &CSGShape3D::update_shape).call_deferred(); // Must be deferred; otherwise, is_root_shape() will use the previous parent.
 	}
 
 	if (!is_root_shape()) {
 		parent_shape->_make_dirty();
 	} else if (!dirty) {
-		callable_mp(this, &CSGShape3D::_update_shape).call_deferred();
+		callable_mp(this, &CSGShape3D::update_shape).call_deferred();
 	}
 
 	dirty = true;
@@ -550,7 +550,7 @@ void CSGShape3D::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const
 	surface.tansw[i++] = d < 0 ? -1 : 1;
 }
 
-void CSGShape3D::_update_shape() {
+void CSGShape3D::update_shape() {
 	if (!is_root_shape()) {
 		return;
 	}
@@ -969,13 +969,13 @@ Ref<TriangleMesh> CSGShape3D::generate_triangle_mesh() const {
 }
 
 void CSGShape3D::_bind_methods() {
-	ClassDB::bind_method(D_METHOD("_update_shape"), &CSGShape3D::_update_shape);
 	ClassDB::bind_method(D_METHOD("is_root_shape"), &CSGShape3D::is_root_shape);
 
 	ClassDB::bind_method(D_METHOD("set_operation", "operation"), &CSGShape3D::set_operation);
 	ClassDB::bind_method(D_METHOD("get_operation"), &CSGShape3D::get_operation);
 
 #ifndef DISABLE_DEPRECATED
+	ClassDB::bind_method(D_METHOD("_update_shape"), &CSGShape3D::update_shape);
 	ClassDB::bind_method(D_METHOD("set_snap", "snap"), &CSGShape3D::set_snap);
 	ClassDB::bind_method(D_METHOD("get_snap"), &CSGShape3D::get_snap);
 #endif // DISABLE_DEPRECATED
diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h
index 5d9131df3214..4214f9486080 100644
--- a/modules/csg/csg_shape.h
+++ b/modules/csg/csg_shape.h
@@ -109,7 +109,6 @@ class CSGShape3D : public GeometryInstance3D {
 	static void mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT,
 			const tbool bIsOrientationPreserving, const int iFace, const int iVert);
 
-	void _update_shape();
 	void _update_collision_faces();
 	bool _is_debug_collision_shape_visible();
 	void _update_debug_collision_shape();
@@ -132,6 +131,7 @@ class CSGShape3D : public GeometryInstance3D {
 
 public:
 	Array get_meshes() const;
+	void update_shape();
 
 	void set_operation(Operation p_operation);
 	Operation get_operation() const;
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 37bd419d6218..c17649f2cbf3 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -5926,7 +5926,7 @@ void GLTFDocument::_convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeInd
 	ERR_FAIL_MSG("csg module is disabled.");
 #else
 	CSGShape3D *csg = p_current;
-	csg->call("_update_shape");
+	csg->update_shape();
 	Array meshes = csg->get_meshes();
 	if (meshes.size() != 2) {
 		return;


Test patch: