Author Topic: Vertices order when adding triangles.  (Read 732 times)

Offline iguatemi

  • byte
  • *
  • Posts: 9
    • View Profile
Vertices order when adding triangles.
« on: January 06, 2017, 06:46:35 pm »
What is the order in which the vertices are sorted to the object3d when using addTriangles?

For example, if I addTriangle(vertex1, vertex2, vertex3), will the vertices be stored in the mesh in the order vertex1, vertex2, vertex3? Is there some logic to it or is it case-by-case?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Vertices order when adding triangles.
« Reply #1 on: January 06, 2017, 07:15:54 pm »
They should, but only if vertex sharing is disabled or all the vertices are unique. Personally, I wouldn't rely on such an assumption though, if I don't have to.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Vertices order when adding triangles.
« Reply #2 on: January 06, 2017, 07:18:01 pm »
But we have to start from somewhere to solve the skinning issue (see the problem visually illustrated on the SkinData thread in Bones).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Vertices order when adding triangles.
« Reply #3 on: January 06, 2017, 07:29:45 pm »
If it helps to solve whatever that issue is, then go ahead.

Offline iguatemi

  • byte
  • *
  • Posts: 9
    • View Profile
Re: Vertices order when adding triangles.
« Reply #4 on: January 06, 2017, 09:25:07 pm »
Thanks!

It actually worked disabling vertex sharing.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Vertices order when adding triangles.
« Reply #5 on: January 08, 2017, 08:59:07 pm »
The second model we tested broke in spite of disabling vertex sharing (and besides, that would have been a costly "solution").

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Vertices order when adding triangles.
« Reply #6 on: January 08, 2017, 09:05:32 pm »
Honestly, I've no idea what you are taking about. If you add the vertices without sharing, they will be added in the order in which you add them. That's all, no further magic involved. If something "breaks" (whatever that means in this context), then this isn't the reason. If you want to be 150% sure, just use the bulk constructor instead: , float[], float[], int[], int)]http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#Object3D(float[], float[], float[], int[], int)

Edit: Crappy Simplemachines forum can't handle this link for whatever reason, but I'm sure you'll be able to find it anyway.
« Last Edit: January 08, 2017, 09:10:13 pm by EgonOlsen »

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Vertices order when adding triangles.
« Reply #7 on: January 10, 2017, 03:02:01 am »
I'll post a screenshot of what it means to break tomorrow. But you said so yourself not to rely on it. And besides, it will be costly not to share vertices, right?

Offline iguatemi

  • byte
  • *
  • Posts: 9
    • View Profile
Re: Vertices order when adding triangles.
« Reply #8 on: January 10, 2017, 07:12:30 pm »
This is what we mean by "break".


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Vertices order when adding triangles.
« Reply #9 on: January 10, 2017, 08:24:30 pm »
No idea what causes this. I can only repeat myself. If you disable sharing, the vertices will be added in order. If you use the bulk constructor, you have even full control about the order. Everything else depends on what you are doing with the data, and I've no clue what that is...