<commit_before>﻿using UnityEngine;
using System.Collections.Generic;
using Network;

namespace Projection{
	public class PositionUpdater : MonoBehaviour {
		/// <summary>
		/// Central level marker, this should be visible. 
		/// </summary>
		Marker parent;
		public float scale=1; 
		/// <summary>
		/// Collection of all registered to this clas. 
		/// </summary>
		private Dictionary<int, Marker> markerTable;
		/// <summary>
		/// register a new marker
		/// </summary>
		public void OnMarkerRegister(MarkerRegister reg){
			markerTable.Add(reg.getMarker().id,reg.getMarker());
			if(parent==null)
				parent=reg.getMarker();
		}
		/// <summary>
		/// gets marker with Identifier  
		/// </summary>
		/// <returns>The marker.</returns>
		/// <param name="id">Identifier.</param>
		/// <exception cref="KeyNotFoundException"> thrown when the marker is not (yet) registered</exception>
		public Marker GetMarker(int id){
			if(markerTable.ContainsKey(id)){
				return markerTable[id];
			}else{
				throw new KeyNotFoundException("this marker is not registered");
			}
		}
		/// <summary>
		/// this marker has been seen by remote, informs the marker of this 
		/// </summary>
		/// <param name="mp">marker position.</param>
		/// <param name="id">Identifier.</param>
		public void OnMarkerSeen(MarkerPosition mp,int id){
			this.GetMarker(id).SetLocalPosition(mp);
		}
		/// <summary>
		/// inform marker that it has received an rotationUpdate 
		/// </summary>
		/// <param name="ru">rotation update.</param>
		public void onRotationUpdate(RotationUpdate ru){
			this.GetMarker(ru.ID).SetObjectRotation(ru.Rotation);
		}
		/// <summary>
		/// Update position of all markers .
		/// </summary>
		public void Update(){
			foreach(KeyValuePair<int, Marker> entry in markerTable)
			{
				updatePosition(entry.Value);
			}
		}
		/// <summary>
		/// uses the market target and parent to set the transform of target
		/// </summary>
		/// <param name="target">Target</param>
		public void updatePosition(Marker target){
            UpdateParentPosition(target);
            UpdateChildPosition(target);
		}

        public void UpdateParentPosition(Marker target)
        {

        }

        public void UpdateChildPosition(Marker target)
        {

        }

		/// <summary>
		/// set the location of the marker based on the remote position. 
		/// </summary>
		/// <param name="pu">position update received over the net.</param>
		public void OnPositionUpdate (PositionUpdate pu){
			this.GetMarker(pu.ID).SetRemotePosition(new MarkerPosition(pu));
		}
	}

}<commit_msg>Final commit of the day, possibly.<commit_after>﻿using UnityEngine;
using System.Collections.Generic;
using Network;

namespace Projection{
	public class PositionUpdater : MonoBehaviour {
		/// <summary>
		/// Central level marker, this should be visible. 
		/// </summary>
		Marker parent;
		public float scale=1; 
		/// <summary>
		/// Collection of all registered to this clas. 
		/// </summary>
		private Dictionary<int, Marker> markerTable;
		/// <summary>
		/// register a new marker
		/// </summary>
		public void OnMarkerRegister(MarkerRegister reg){
			markerTable.Add(reg.getMarker().id,reg.getMarker());
			if(parent==null)
				parent=reg.getMarker();
		}
		/// <summary>
		/// gets marker with Identifier  
		/// </summary>
		/// <returns>The marker.</returns>
		/// <param name="id">Identifier.</param>
		/// <exception cref="KeyNotFoundException"> thrown when the marker is not (yet) registered</exception>
		public Marker GetMarker(int id){
			if(markerTable.ContainsKey(id)){
				return markerTable[id];
			}else{
				throw new KeyNotFoundException("this marker is not registered");
			}
		}
		/// <summary>
		/// this marker has been seen by remote, informs the marker of this 
		/// </summary>
		/// <param name="mp">marker position.</param>
		/// <param name="id">Identifier.</param>
		public void OnMarkerSeen(MarkerPosition mp,int id){
			this.GetMarker(id).SetLocalPosition(mp);
		}
		/// <summary>
		/// inform marker that it has received an rotationUpdate 
		/// </summary>
		/// <param name="ru">rotation update.</param>
		public void onRotationUpdate(RotationUpdate ru){
			this.GetMarker(ru.ID).SetObjectRotation(ru.Rotation);
		}
		/// <summary>
		/// Update position of all markers .
		/// </summary>
		public void Update(){
			foreach(KeyValuePair<int, Marker> entry in markerTable)
			{
				updatePosition(entry.Value);
			}
		}
		/// <summary>
		/// uses the market target and parent to set the transform of target
		/// </summary>
		/// <param name="target">Target</param>
		public void updatePosition(Marker target)
        {
            if (target == parent)
            {
                UpdateParentPosition(target);
            }
            else
            {
                UpdateChildPosition(target);
            }
		}

        /// <summary>
        /// Updates position if supplied target is the parent.
        /// </summary>
        /// <param name="target">The supplied target.</param>
        public void UpdateParentPosition(Marker target)
        {
            target.gameObject.transform.position = target.localPosition.Position;
            Vector3 localrotation = target.localPosition.Rotation.eulerAngles;
            Vector3 remoterotation = target.remotePosition.Rotation.eulerAngles;
            Vector3 finalrotation = localrotation - remoterotation;
            target.gameObject.transform.rotation = Quaternion.Euler(finalrotation);
        }

        /// <summary>
        /// Updates position if supplied target is not the parent.
        /// </summary>
        /// <param name="target">The supplied target.</param>
        public void UpdateChildPosition(Marker target)
        {
            target.gameObject.transform.position = target.remotePosition.Position - parent.remotePosition.Position;
            // TODO: If mirrored then swap operation params.
        }

		/// <summary>
		/// set the location of the marker based on the remote position. 
		/// </summary>
		/// <param name="pu">position update received over the net.</param>
		public void OnPositionUpdate (PositionUpdate pu){
			this.GetMarker(pu.ID).SetRemotePosition(new MarkerPosition(pu));
		}
	}

}
{'fraction_non_alphanumeric': 0.1344294003868472, 'fraction_numerical': 0.0008059316569954867, 'mean_word_length': 2.702267303102625, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 83, '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': '4327490', 'n_tokens_mistral': 1899, 'n_tokens_neox': 1700, 'n_words': 468}