Repository: godotengine/godot
File: editor/scene/3d/gizmos/spring_bone_3d_gizmo_plugin.cpp (C++)

Code before:

	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::UP * p_radius).rotated(Vector3::RIGHT, SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::UP * p_radius).rotated(Vector3::RIGHT, SPPI * (i % STEP)));
	}
	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::RIGHT * p_radius).rotated(Vector3::FORWARD, SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::RIGHT * p_radius).rotated(Vector3::FORWARD, SPPI * (i % STEP)));
	}
	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::FORWARD * p_radius).rotated(Vector3::UP, SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::FORWARD * p_radius).rotated(Vector3::UP, SPPI * (i % STEP)));
	}
}

void SpringBoneCollision3DGizmoPlugin::draw_capsule(Ref<SurfaceTool> &p_surface_tool, float p_radius, float p_height, const Color &p_color) {
	static constexpr int STEP = 16;
	static constexpr int HALF_STEP = 8;
	static constexpr float SPPI = Math::TAU / (float)STEP;
	static constexpr float HALF_PI = Math::PI * 0.5;

	Vector3 top = Vector3::UP * (p_height * 0.5 - p_radius);
	Vector3 bottom = -top;

	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((i - 1 < HALF_STEP ? top : bottom) + (Vector3::UP * p_radius).rotated(Vector3::RIGHT, -HALF_PI + SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((i - 1 < HALF_STEP ? top : bottom) + (Vector3::UP * p_radius).rotated(Vector3::RIGHT, -HALF_PI + SPPI * (i % STEP)));
	}
	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((i - 1 < HALF_STEP ? top : bottom) + (Vector3::RIGHT * p_radius).rotated(Vector3::FORWARD, SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((i - 1 < HALF_STEP ? top : bottom) + (Vector3::RIGHT * p_radius).rotated(Vector3::FORWARD, SPPI * (i % STEP)));
	}
	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex(top + (Vector3::FORWARD * p_radius).rotated(Vector3::UP, SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex(top + (Vector3::FORWARD * p_radius).rotated(Vector3::UP, SPPI * (i % STEP)));
	}
	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex(bottom + (Vector3::FORWARD * p_radius).rotated(Vector3::UP, SPPI * ((i - 1) % STEP)));

Review comment (suggestion):
```suggestion
	static constexpr float HALF_PI = Math::PI * 0.5f;
```

Code after:

	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::UP * p_radius).rotated(Vector3::RIGHT, SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::UP * p_radius).rotated(Vector3::RIGHT, SPPI * (i % STEP)));
	}
	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::RIGHT * p_radius).rotated(Vector3::FORWARD, SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::RIGHT * p_radius).rotated(Vector3::FORWARD, SPPI * (i % STEP)));
	}
	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::FORWARD * p_radius).rotated(Vector3::UP, SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((Vector3::FORWARD * p_radius).rotated(Vector3::UP, SPPI * (i % STEP)));
	}
}

void SpringBoneCollision3DGizmoPlugin::draw_capsule(Ref<SurfaceTool> &p_surface_tool, float p_radius, float p_height, const Color &p_color) {
	static constexpr int STEP = 16;
	static constexpr int HALF_STEP = 8;
	static constexpr float SPPI = (float)Math::TAU / STEP;
	static constexpr float HALF_PI = (float)Math::PI * 0.5f;

	Vector3 top = Vector3::UP * (p_height * 0.5 - p_radius);
	Vector3 bottom = -top;

	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((i - 1 < HALF_STEP ? top : bottom) + (Vector3::UP * p_radius).rotated(Vector3::RIGHT, -HALF_PI + SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((i - 1 < HALF_STEP ? top : bottom) + (Vector3::UP * p_radius).rotated(Vector3::RIGHT, -HALF_PI + SPPI * (i % STEP)));
	}
	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((i - 1 < HALF_STEP ? top : bottom) + (Vector3::RIGHT * p_radius).rotated(Vector3::FORWARD, SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex((i - 1 < HALF_STEP ? top : bottom) + (Vector3::RIGHT * p_radius).rotated(Vector3::FORWARD, SPPI * (i % STEP)));
	}
	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex(top + (Vector3::FORWARD * p_radius).rotated(Vector3::UP, SPPI * ((i - 1) % STEP)));
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex(top + (Vector3::FORWARD * p_radius).rotated(Vector3::UP, SPPI * (i % STEP)));
	}
	for (int i = 1; i <= STEP; i++) {
		p_surface_tool->set_color(p_color);
		p_surface_tool->add_vertex(bottom + (Vector3::FORWARD * p_radius).rotated(Vector3::UP, SPPI * ((i - 1) % STEP)));