Search Unity

Feedback DOTS Rotation And Translation Not working

Discussion in 'Data Oriented Technology Stack' started by cloud1989, Aug 19, 2019.

?

DOTS Rotation And Translation Not working

  1. Why?

    0 vote(s)
    0.0%
  2. What?

    5 vote(s)
    100.0%
  1. cloud1989

    cloud1989

    Joined:
    May 30, 2016
    Posts:
    32
    Code (CSharp):
    1.         public void Execute(ref Rotation rotation, ref HexCellData hexCellData)
    2.         {
    3.             rotation.Value = math.mul(math.normalize(rotation.Value), quaternion.AxisAngle(math.up(), hexCellData.RadiansPerSecond * DeltaTime));
    4.         }
    No,not working any more with the newest preview version.
    Code (CSharp):
    1.         public void Execute(Entity entity, int index, [ReadOnly]ref Translation position)
    2.         {
    3.             var currentPosition = position.Value;
    4.  
    5.             Vector3 center = new Vector3
    6.             {
    7.                 x = currentPosition.x,
    8.                 y = currentPosition.y,
    9.                 z = currentPosition.z
    10.             };
    11.             Vertices[index] = center;
    12.  
    13.         }
    Nope,this is not working,Translation is all o! But it's viewing on debuger.I can see Translation.x Translation.y,Translation.z ,just can not get the data.
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    424
    What version was this working before? How are you creating your entities?
     
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,423
    All works. From which version you updated?
     
  4. cloud1989

    cloud1989

    Joined:
    May 30, 2016
    Posts:
    32
  5. cloud1989

    cloud1989

    Joined:
    May 30, 2016
    Posts:
    32
    public struct HexMeshData : IComponentData {
    //public float3[] Vertices;ArgumentException: HexMeshData contains a field of UnityEngine.float3[], which is neither primitive nor blittable.
    //public Vector3[] Vertices;//ArgumentException: HexMeshData contains a field of UnityEngine.Vector3[], which is neither primitive nor blittable.
    }
    I want to know which field is primitive and blittable! Thx a lot!
     
  6. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    69
    I don't believe that you can use managed arrays within a componentdata. You should use float3 for your data, but store it in a buffer element

    Code (CSharp):
    1. public struct  Vertex : IBufferElementData
    2. {
    3.     public float3 value;
    4. }
    You should then add a buffer of Vertex elements to your entity.
     
  7. cloud1989

    cloud1989

    Joined:
    May 30, 2016
    Posts:
    32
    Thanks,man.Then how to use it in a job,like for loop.
     
  8. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    69
  9. cloud1989

    cloud1989

    Joined:
    May 30, 2016
    Posts:
    32
    Just don't understand this.The codes just doesn't look like a list,if it's a list I can use Add method which is the way I like.If there is a full project example I would better understand it.
    Thanks anyway.
     
  10. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    1,656
    It pretty much works exactly like a list. Here are it's methods (excluding extensions)

    Code (CSharp):
    1. struct DynamicBuffer<T> : IEnumerable<T> where T : struct
    2.  
    3.         public int Length { get; }
    4.         public int Capacity { get; }
    5.         public bool IsCreated { get; }
    6.  
    7.         public T this [int index] { get; set; }
    8.  
    9.         public void ResizeUninitialized(int length)
    10.         public void Reserve(int length)
    11.         public void Clear()
    12.         public void TrimExcess()
    13.         public int Add(T elem)
    14.         public void Insert(int index, T elem)
    15.         public void AddRange(NativeArray<T> newElems)
    16.         public void RemoveRange(int index, int count)
    17.         public void RemoveAt(int index)
     
  11. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    5,385
    See my description for buffer. May be useful. However, you are recommended to have Unity 2018, since I haven't updated. But with small taking, will work in 2019.
     
  12. cloud1989

    cloud1989

    Joined:
    May 30, 2016
    Posts:
    32
    Thanks man.Gotcha!
     
  13. cloud1989

    cloud1989

    Joined:
    May 30, 2016
    Posts:
    32
    Hey man.Translation is working,Rotation still not.Thank you anyway.
    Codes is here:https://github.com/cloudhu/HexMapMadeInUnity2019ECS
     
    Antypodish likes this.