<commit_before>﻿using UnityEngine;
using UnityEngine.Rendering;

// Skidmarks controller. Put one of these in a scene somewhere. Call AddSkidMark.
// Copyright 2017 Nition, BSD licence (see LICENCE file). http://nition.co
public class Skidmarks : MonoBehaviour {
	// INSPECTOR SETTINGS

	[SerializeField]
	Material skidmarksMaterial; // Material for the skidmarks to use

	// END INSPECTOR SETTINGS

	const int MAX_MARKS = 2048; // Max number of marks total for everyone together
	const float MARK_WIDTH = 0.35f; // Width of the skidmarks. Should match the width of the wheels
	const float GROUND_OFFSET = 0.02f;  // Distance above surface in metres
	const float MIN_DISTANCE = 0.25f; // Distance between skid texture sections in metres. Bigger = better performance, less smooth
	const float MIN_SQR_DISTANCE = MIN_DISTANCE * MIN_DISTANCE;

	// Info for each mark created. Needed to generate the correct mesh
	class MarkSection {
		public Vector3 Pos = Vector3.zero;
		public Vector3 Normal = Vector3.zero;
		public Vector4 Tangent = Vector4.zero;
		public Vector3 Posl = Vector3.zero;
		public Vector3 Posr = Vector3.zero;
		public byte Intensity;
		public int LastIndex;
	};

	int markIndex;
	MarkSection[] skidmarks;
	Mesh marksMesh;
	MeshRenderer mr;
	MeshFilter mf;

	Vector3[] vertices;
	Vector3[] normals;
	Vector4[] tangents;
	Color32[] colors;
	Vector2[] uvs;
	int[] triangles;

	bool meshUpdated;
	bool haveSetBounds;

	// #### UNITY INTERNAL METHODS ####

	protected void Start() {
		// Generate a fixed array of skidmarks
		skidmarks = new MarkSection[MAX_MARKS];
		for (int i = 0; i < MAX_MARKS; i++) {
			skidmarks[i] = new MarkSection();
		}

		mf = GetComponent<MeshFilter>();
		mr = GetComponent<MeshRenderer>();
		if (mr == null) {
			mr = gameObject.AddComponent<MeshRenderer>();
		}
		marksMesh = new Mesh();
		marksMesh.MarkDynamic();
		if (mf == null) {
			mf = gameObject.AddComponent<MeshFilter>();
		}
		mf.sharedMesh = marksMesh;<commit_msg>Add check for transform at origin<commit_after>﻿using UnityEngine;
using UnityEngine.Rendering;

// Skidmarks controller. Put one of these in a scene somewhere. Call AddSkidMark.
// Copyright 2017 Nition, BSD licence (see LICENCE file). http://nition.co
public class Skidmarks : MonoBehaviour {
	// INSPECTOR SETTINGS

	[SerializeField]
	Material skidmarksMaterial; // Material for the skidmarks to use

	// END INSPECTOR SETTINGS

	const int MAX_MARKS = 2048; // Max number of marks total for everyone together
	const float MARK_WIDTH = 0.35f; // Width of the skidmarks. Should match the width of the wheels
	const float GROUND_OFFSET = 0.02f;  // Distance above surface in metres
	const float MIN_DISTANCE = 0.25f; // Distance between skid texture sections in metres. Bigger = better performance, less smooth
	const float MIN_SQR_DISTANCE = MIN_DISTANCE * MIN_DISTANCE;

	// Info for each mark created. Needed to generate the correct mesh
	class MarkSection {
		public Vector3 Pos = Vector3.zero;
		public Vector3 Normal = Vector3.zero;
		public Vector4 Tangent = Vector4.zero;
		public Vector3 Posl = Vector3.zero;
		public Vector3 Posr = Vector3.zero;
		public byte Intensity;
		public int LastIndex;
	};

	int markIndex;
	MarkSection[] skidmarks;
	Mesh marksMesh;
	MeshRenderer mr;
	MeshFilter mf;

	Vector3[] vertices;
	Vector3[] normals;
	Vector4[] tangents;
	Color32[] colors;
	Vector2[] uvs;
	int[] triangles;

	bool meshUpdated;
	bool haveSetBounds;

	// #### UNITY INTERNAL METHODS ####

	protected void Awake() {
		if (transform.position != Vector3.zero) {
			Debug.LogWarning("Skidmarks.cs transform must be at 0,0,0. Setting it to zero now.");
			transform.position = Vector3.zero;
			transform.rotation = Quaternion.identity;
		}
	}

	protected void Start() {
		// Generate a fixed array of skidmarks
		skidmarks = new MarkSection[MAX_MARKS];
		for (int i = 0; i < MAX_MARKS; i++) {
			skidmarks[i] = new MarkSection();
		}

		mf = GetComponent<MeshFilter>();
		mr = GetComponent<MeshRenderer>();
		if (mr == null) {
			mr = gameObject.AddComponent<MeshRenderer>();
		}
		marksMesh = new Mesh();
		marksMesh.MarkDynamic();
		if (mf == null) {
			mf = gameObject.AddComponent<MeshFilter>();
		}
		mf.sharedMesh = marksMesh;
{'fraction_non_alphanumeric': 0.09919124643196955, 'fraction_numerical': 0.01736441484300666, 'mean_word_length': 3.9704491725768323, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '908921', 'n_tokens_mistral': 1455, 'n_tokens_neox': 1313, 'n_words': 445}