<commit_before>﻿using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;

public class Drag : MonoBehaviour
{
    public LayerMask RaycastLayers;

    [Tooltip("Maximum raycast distance")]
    public float MaxDist = 4;

    [Tooltip("Scalar force for dragging")]
    public float DragForce = 1f;

    // member variables for dragging
    private Rigidbody selectedBody;
    private float selectionDist;
    private Vector3 bodyLocalPoint;

    private DebugRenderer debug;

    // Use this for initialization
    void Start()
    {
        // find debug renderer
        debug = FindObjectOfType<DebugRenderer>();
    }

    private void raycastSelect()
    {
        Ray ray = new Ray(transform.position, transform.forward); // raycast forward

        RaycastHit hit;
        if (Physics.Raycast(ray, out hit, MaxDist, RaycastLayers)
            && hit.rigidbody)
        {
            selectedBody = hit.rigidbody;
            selectionDist = hit.distance;
            bodyLocalPoint = hit.transform.InverseTransformPoint(hit.point);
        }

        // draw debug
        if (debug)
            debug.DrawLine(ray.origin, ray.origin + ray.direction * hit.distance, debug.Materials[3]);
    }

    private void dragSelected()
    {
        Vector3 selWorldPos = selectedBody.transform.TransformPoint(bodyLocalPoint);
        Vector3 curWorldPos = transform.position + transform.forward * selectionDist;

        Vector3 delta = curWorldPos - selWorldPos;

        selectedBody.AddForceAtPosition(delta * DragForce, selWorldPos);

        // draw debug
        if (debug)
        {
            debug.DrawLine(transform.position, curWorldPos, debug.Materials[3]);
            debug.DrawCrosshair(selWorldPos, 0.4f, debug.Materials[0]);
            debug.DrawCrosshair(curWorldPos, 0.4f, debug.Materials[1]);
        }

    }

    private void clearSelect()
    {
        selectedBody = null;
        selectionDist = 0f;
        bodyLocalPoint = Vector3.zero;
    }

    // Update is called once per frame
    void Update()
    {<commit_msg>force scaled by deltatime<commit_after>﻿using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;

public class Drag : MonoBehaviour
{
    public LayerMask RaycastLayers;

    [Tooltip("Maximum raycast distance")]
    public float MaxDist = 4;

    [Tooltip("Scalar force for dragging")]
    public float DragForce = 1f;

    // member variables for dragging
    private Rigidbody selectedBody;
    private float selectionDist;
    private Vector3 bodyLocalPoint;

    private DebugRenderer debug;

    // Use this for initialization
    void Start()
    {
        // find debug renderer
        debug = FindObjectOfType<DebugRenderer>();
    }

    private void raycastSelect()
    {
        Ray ray = new Ray(transform.position, transform.forward); // raycast forward

        RaycastHit hit;
        if (Physics.Raycast(ray, out hit, MaxDist, RaycastLayers)
            && hit.rigidbody)
        {
            selectedBody = hit.rigidbody;
            selectionDist = hit.distance;
            bodyLocalPoint = hit.transform.InverseTransformPoint(hit.point);
        }

        // draw debug
        if (debug)
            debug.DrawLine(ray.origin, ray.origin + ray.direction * hit.distance, debug.Materials[3]);
    }

    private void dragSelected()
    {
        Vector3 selWorldPos = selectedBody.transform.TransformPoint(bodyLocalPoint);
        Vector3 curWorldPos = transform.position + transform.forward * selectionDist;

        Vector3 delta = curWorldPos - selWorldPos;

        selectedBody.AddForceAtPosition(delta * DragForce * Time.deltaTime * 60f, selWorldPos);

        // draw debug
        if (debug)
        {
            debug.DrawLine(transform.position, curWorldPos, debug.Materials[3]);
            debug.DrawCrosshair(selWorldPos, 0.4f, debug.Materials[0]);
            debug.DrawCrosshair(curWorldPos, 0.4f, debug.Materials[1]);
        }

    }

    private void clearSelect()
    {
        selectedBody = null;
        selectionDist = 0f;
        bodyLocalPoint = Vector3.zero;
    }

    // Update is called once per frame
    void Update()
    {
{'fraction_non_alphanumeric': 0.08916125931266522, 'fraction_numerical': 0.008171112713290074, 'mean_word_length': 2.43682906688687, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5178884', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1111, 'n_words': 279}