Protfolio-Emanuel-Polsky / Assets / _Project / Code / VerletIntegration / Component / Point.cs
Point.cs
Raw
using System;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics.Systems;

namespace GarmentButton.VerletIntegration
{
    public enum PointState : byte  { Free, Boarder, Loosed}
    [Serializable]
    public struct Point : IBufferElementData
    {
        public float3 Position, PrevesPosition;
        public bool IsLocked;
        public PointState State;
    }
    [Serializable]
    public struct StickPartiallyMono : IEquatable<StickPartiallyMono>
    {
        public short PointA, PointB;
        public ushort Lenght;

        public bool Equals(StickPartiallyMono other)
        {
            var isOneWayEqual = PointA == other.PointA && PointB == other.PointB;
            var isOtherWayEqual = PointB == other.PointA && PointA == other.PointB;
            return (isOneWayEqual || isOtherWayEqual);
        }
    }
    public struct Stick : IBufferElementData
    {
        public short PointA, PointB;
        public bool Active;
        /// <summary>
        /// I multiplay the lenght by 100 to keep it over the dot, and than multiplay it by 0.01 back to normal
        /// </summary>
        public ushort Lenght;
        
        public const float CONVERTION_RATE = 0.01f;
    }


    public struct Tringle : IBufferElementData
    {
        public short Index;
    }
    public struct FlagData : IComponentData
    {
        public byte NumberIterations;
        public float GravityForce;
        public float Damping;
    }
    public struct BoundBox : IComponentData
    {
        public float3 Min;
        public float3 Max;
    }

    public struct RelativeLock : IBufferElementData
    {
        public ushort Index;
        public float3 OffSet;
    }

    //Cache Lengths
    public struct PointArrayLenght : IComponentData
    {
        public ushort Value;
    }
    public struct TringleArrayLenght : IComponentData
    {
        public ushort Value;
    }
    public struct SticksArrayLenght : IComponentData
    {
        public ushort Value;
    }


    public struct RecordLastTransform : IComponentData
    {
        public float3 Position;
        public quaternion Rotation;
    }

    public struct DebugClothTag : IComponentData{}
    

}