<commit_before>#include "collision_shape_2d_editor_plugin.h"

#include "canvas_item_editor_plugin.h"

#include "scene/resources/segment_shape_2d.h"
#include "scene/resources/shape_line_2d.h"
#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/capsule_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"

Variant CollisionShape2DEditor::get_handle_value(int idx) const {

	switch ( shape_type ) {
		case CAPSULE_SHAPE: {
			Ref<CapsuleShape2D> capsule = node->get_shape();

			if (idx==0) {
				return capsule->get_radius();
			} else if (idx==1) {
				return capsule->get_height();
			}

		} break;

		case CIRCLE_SHAPE: {
			Ref<CircleShape2D> circle = node->get_shape();

			if (idx==0) {
				return circle->get_radius();
			}

		} break;

		case CONCAVE_POLYGON_SHAPE: {

		} break;

		case CONVEX_POLYGON_SHAPE: {

		} break;

		case LINE_SHAPE: {

		} break;

		case RAY_SHAPE: {
			Ref<RayShape2D> ray = node->get_shape();

			if (idx==0) {
				return ray->get_length();
			}

		} break;

		case RECTANGLE_SHAPE: {
			Ref<RectangleShape2D> rect = node->get_shape();

			if (idx<2) {
				return rect->get_extents().abs();
			}

		} break;

		case SEGMENT_SHAPE: {
			Ref<SegmentShape2D> seg = node->get_shape();

			if (idx==0) {
				return seg->get_a();
			} else if (idx==1) {
				return seg->get_b();
			}

		} break;
	}

	return Variant();
}

void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) {

	switch ( shape_type ) {
		case CAPSULE_SHAPE: {
			if (idx < 2) {
				Ref<CapsuleShape2D> capsule = node->get_shape();

				real_t parameter = Math::abs(p_point[idx]);

				if (idx==0) {
					capsule->set_radius(parameter);
				} else if (idx==1){
					capsule->set_height(parameter*2 - capsule->get_radius()*2);
				}

				canvas_item_editor->get_viewport_control()->update();
			}

		} break;

		case CIRCLE_SHAPE: {
			Ref<CircleShape2D> circle = node->get_shape();
			circle->set_radius(p_point.length());

			canvas_item_editor->get_viewport_control()->update();

		} break;

		case CONCAVE_POLYGON_SHAPE: {

		} break;

		case CONVEX_POLYGON_SHAPE: {

		} break;

		case LINE_SHAPE: {
			if (idx<2) {
				Ref<LineShape2D> line = node->get_shape();

				if (idx==0){
					line->set_d(p_point.length());
				}else{
					line->set_normal(p_point/30.0);
				}

				canvas_item_editor->get_viewport_control()->update();
			}


		} break;

		case RAY_SHAPE: {
			Ref<RayShape2D> ray = node->get_shape();

			ray->set_length(Math::abs(p_point.y));

			canvas_item_editor->get_viewport_control()->update();

		} break;
<commit_msg>get_handle_value implemented for LINE_SHAPE. Normal length normalized.<commit_after>#include "collision_shape_2d_editor_plugin.h"

#include "canvas_item_editor_plugin.h"

#include "scene/resources/segment_shape_2d.h"
#include "scene/resources/shape_line_2d.h"
#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/capsule_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"

Variant CollisionShape2DEditor::get_handle_value(int idx) const {

	switch ( shape_type ) {
		case CAPSULE_SHAPE: {
			Ref<CapsuleShape2D> capsule = node->get_shape();

			if (idx==0) {
				return capsule->get_radius();
			} else if (idx==1) {
				return capsule->get_height();
			}

		} break;

		case CIRCLE_SHAPE: {
			Ref<CircleShape2D> circle = node->get_shape();

			if (idx==0) {
				return circle->get_radius();
			}

		} break;

		case CONCAVE_POLYGON_SHAPE: {

		} break;

		case CONVEX_POLYGON_SHAPE: {

		} break;

		case LINE_SHAPE: {
			Ref<LineShape2D> line = node->get_shape();

			if (idx==0) {
				return line->get_d();
			} else {
				return line->get_normal();
			}

		} break;

		case RAY_SHAPE: {
			Ref<RayShape2D> ray = node->get_shape();

			if (idx==0) {
				return ray->get_length();
			}

		} break;

		case RECTANGLE_SHAPE: {
			Ref<RectangleShape2D> rect = node->get_shape();

			if (idx<2) {
				return rect->get_extents().abs();
			}

		} break;

		case SEGMENT_SHAPE: {
			Ref<SegmentShape2D> seg = node->get_shape();

			if (idx==0) {
				return seg->get_a();
			} else if (idx==1) {
				return seg->get_b();
			}

		} break;
	}

	return Variant();
}

void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) {

	switch ( shape_type ) {
		case CAPSULE_SHAPE: {
			if (idx < 2) {
				Ref<CapsuleShape2D> capsule = node->get_shape();

				real_t parameter = Math::abs(p_point[idx]);

				if (idx==0) {
					capsule->set_radius(parameter);
				} else if (idx==1){
					capsule->set_height(parameter*2 - capsule->get_radius()*2);
				}

				canvas_item_editor->get_viewport_control()->update();
			}

		} break;

		case CIRCLE_SHAPE: {
			Ref<CircleShape2D> circle = node->get_shape();
			circle->set_radius(p_point.length());

			canvas_item_editor->get_viewport_control()->update();

		} break;

		case CONCAVE_POLYGON_SHAPE: {

		} break;

		case CONVEX_POLYGON_SHAPE: {

		} break;

		case LINE_SHAPE: {
			if (idx<2) {
				Ref<LineShape2D> line = node->get_shape();

				if (idx==0){
					line->set_d(p_point.length());
				}else{
					line->set_normal(p_point.normalized());
				}

				canvas_item_editor->get_viewport_control()->update();
			}


		} break;

		case RAY_SHAPE: {
			Ref<RayShape2D> ray = node->get_shape();

			ray->set_length(Math::abs(p_point.y));

			canvas_item_editor->get_viewport_control()->update();

		} break;

{'fraction_non_alphanumeric': 0.15126502781266823, 'fraction_numerical': 0.013098869549614211, 'mean_word_length': 3.6801007556675063, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6984657', 'n_tokens_mistral': 2569, 'n_tokens_neox': 2135, 'n_words': 334}